Skip to content

Instantly share code, notes, and snippets.

@jairhenrique
Last active February 26, 2022 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jairhenrique/e218e194656eef1996ece931c4ad15a3 to your computer and use it in GitHub Desktop.
Save jairhenrique/e218e194656eef1996ece931c4ad15a3 to your computer and use it in GitHub Desktop.
class Pessoa:
def __init__(self, nome, idade):
self.nome = nome
self.idade = idade
pessoa = Pessoa('João', 20)
print(pessoa.__dict__)
# {'nome': 'João', 'idade': 20}
pessoa.sobrenome = 'Silva'
print(pessoa.__dict__)
# {'nome': 'João', 'idade': 20, 'sobrenome': 'Silva'}
print(pessoa.sobrenome)
# Silva
print(Pessoa.__dict__)
# {'__module__': '__main__', '__init__': <function Pessoa.__init__ at 0x10afd55e0>, '__dict__': <attribute '__dict__' of 'Pessoa' objects>, '__weakref__': <attribute '__weakref__' of 'Pessoa' objects>, '__doc__': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment