We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a35eae4 commit de85dd7Copy full SHA for de85dd7
1 file changed
oo/pessoa.py
@@ -1,17 +1,19 @@
1
class Pessoa:
2
- def __init__(self, nome=None, idade=47):
+ def __init__(self, nome=None, idade=47, *filhos):
3
self.nome = nome
4
self.idade = idade
5
+ self.filhos = list(filhos)
6
7
def cumprimentar(self):
8
return f'Olá {id(self)}'
9
10
11
if __name__ == '__main__':
- p = Pessoa('Itiro')
12
- print(Pessoa.cumprimentar(p))
13
- print(id(p))
14
- print(p.cumprimentar())
15
- print(p.nome)
16
- p.nome = 'Alexandre'
17
+ alex = Pessoa(nome='Alex')
+ itiro = Pessoa('Itiro', 47, alex)
+ print(Pessoa.cumprimentar(itiro))
+ print(id(itiro))
+ print(itiro.cumprimentar())
+ print(itiro.nome)
18
+ for filho in itiro.filhos:
19
+ print(filho.nome)
0 commit comments