File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .gitignore
2+
13# Byte-compiled / optimized / DLL files
24__pycache__ /
35* .py [cod ]
@@ -6,6 +8,7 @@ __pycache__/
68* .so
79
810# Distribution / packaging
11+ venv /
912.Python
1013env /
1114bin /
@@ -52,4 +55,3 @@ coverage.xml
5255
5356# Sphinx documentation
5457docs /_build /
55-
Original file line number Diff line number Diff line change 11class Pessoa :
2- def __init__ (self , * filhos , nome = None , idade = 41 ):
2+ def __init__ (self , * filhos , nome = None , idade = 0 ):
33 self .nome = nome
44 self .idade = idade
55 self .filhos = list (filhos )
@@ -18,8 +18,6 @@ def __repr__(self):
1818 return txtSaida
1919
2020
21-
22-
2321if __name__ == '__main__' :
2422 filhos = [('Arthur' , 7 ), ('Alice' , 0 )]
2523
@@ -29,3 +27,15 @@ def __repr__(self):
2927 pai .filhos .append (Pessoa (nome = filho [0 ], idade = filho [1 ]))
3028
3129 print (pai )
30+
31+ # O atributo __dict__ lista todos os atributos de instancia de um objeto.
32+
33+ # Imprimindo o objeto ANTES da criacao de um atributo de instancia
34+ print (pai .__dict__ )
35+
36+ # Criando um atributo booleano 'casado' no objeto 'pai'
37+ # (esse atributo nao existe em outros objetos da classe Pessoa
38+ pai .casado = True
39+
40+ # Imprimindo novamente os atributos de instancia
41+ print (pai .__dict__ )
You can’t perform that action at this time.
0 commit comments