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:
2020 # Assegna l'argomento all'attributo name dell'istanza
2121 self .name = name
2222
23- # Inizializza una proprietà
24- self ._age = 0
23+ # Inizializza una proprietà
24+ self ._age = 0
2525
26- # Un metodo dell'istanza. Tutti i metodi prendo "self"
26+ # Un metodo dell'istanza. Tutti i metodi prendono "self"
2727 # come primo argomento
2828 def say (self , msg ):
2929 print (" {name} : {message} " .format(name = self .name, message = msg))
@@ -45,7 +45,7 @@ class Human:
4545 return " *grunt*"
4646
4747 # 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,
4949 # che ha lo stesso nome
5050 @ property
5151 def age (self ):
@@ -94,7 +94,7 @@ if __name__ == '__main__':
9494 i.age = 42
9595 # Leggi la property
9696 i.say(i.age) # => "Ian: 42"
97- j.say(j.age) # => "Joel: 0"
97+ j.say(j.age) # => "Joel: 0"
9898 # Cancella la property
9999 del i.age
100100 i.age # => questo genererà un AttributeError
You can’t perform that action at this time.
0 commit comments