Thông Đặng
Thông Đặng

Reputation: 51

Python Error object() takes no parameters

I have 2 file Python: Pet.py

class Pet(object):
 def __int__(self, name, species):
  self.name = name
  self.species = species

 def getName(self):
  return self.name

 def getSpecies(self):
  return self.species

 def __str__(self):
  return "%s is %s" % (self.name, self.species)

And file petobject.py

from Pet import Pet
polly = Pet("Polly", "Parrot")
print "Polly is a %s" % polly.getSpecies()

When I run petobject.py I got this error : object() takes no parameters. Please help me with this error.

Upvotes: 0

Views: 159

Answers (1)

agold
agold

Reputation: 6276

Your class init function is spelled wrongly, this should be __init__ instead of __int__:

def __init__(self, name, species):

Upvotes: 1

Related Questions