File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,10 @@ class Human:
20
20
# Assegna l'argomento all'attributo name dell'istanza
21
21
self .name = name
22
22
23
- # Inizializza una proprietà
24
- self ._age = 0
23
+ # Inizializza una proprietà
24
+ self ._age = 0
25
25
26
- # Un metodo dell'istanza. Tutti i metodi prendo "self"
26
+ # Un metodo dell'istanza. Tutti i metodi prendono "self"
27
27
# come primo argomento
28
28
def say (self , msg ):
29
29
print (" {name} : {message} " .format(name = self .name, message = msg))
@@ -45,7 +45,7 @@ class Human:
45
45
return " *grunt*"
46
46
47
47
# Una property è come un metodo getter.
48
- # Trasforma il metodo age() in un attributo in sola lettura,
48
+ # Trasforma il metodo age() in un attributo in sola lettura,
49
49
# che ha lo stesso nome
50
50
@ property
51
51
def age (self ):
@@ -94,7 +94,7 @@ if __name__ == '__main__':
94
94
i.age = 42
95
95
# Leggi la property
96
96
i.say(i.age) # => "Ian: 42"
97
- j.say(j.age) # => "Joel: 0"
97
+ j.say(j.age) # => "Joel: 0"
98
98
# Cancella la property
99
99
del i.age
100
100
i.age # => questo genererà un AttributeError
You can’t perform that action at this time.
0 commit comments