0
I am learning POO in python, I have created a client class that has three attributes; name, Cpf and age. And I also created a method that stores these attributes inside a tuple and returns this tuple. But the method did not return the tuple, it returned this:
<bound method Cliente.dados of <__main__.Cliente object at 0x7f8788c67940>>
I can’t understand why.
Method:
def dados():
"""
método criado para retornar todos os dados em uma tupla
"""
dados = (self.nome,self.idade,self.cpf)
return dados
Instance
clientes = Cliente('Joaquin',21,'04040505')
print(clientes.dados)
It worked now, but because I have to put the self as a parameter?
– Eudson Durães
@eudsonduraes https://answall.com/q/176543/112052
– hkotsubo
Dude, it’s but a convention, it’s not mandatory. correct on the answer, but it’s to say that it belongs to a class, in that link explains well
– Tmilitino
In fact, if it is a method there should always be a first parameter that will be reference to the instance itself; only the name
self
convention.– Woss