Reputation: 609
This class has a function name
, which should return the dog's name ("Boby"
in following the example).
class Dog(object):
def __init__(EstePerro, Nombre=None, Peso=None):
EstePerro._Name = Nombre
EstePerro._Weight = Peso
def name(EstePerro):
"Returns dog name"
return EstePerro._Name
pet = Dog("Boby",45)
print(pet.name)
But instead it returns this:
<bound method Dog.name of <__main__.Dog object at 0x0000000002DD4748>>
What am I doing wrong?
Upvotes: 0
Views: 47
Reputation: 10138
pet.name
is your methodpet.name()
is a call to your methodSo here, you need to add parenthesis to call your name
method:
>>> pet = Dog("Boby", 45)
>>> print(pet.name()) # Parentheses after pet.name
Boby
Upvotes: 2