Last active
February 26, 2022 14:24
-
-
Save jairhenrique/e218e194656eef1996ece931c4ad15a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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