father class name

C

contro opinion

here is my haha class
class haha(object):
def theprint(self):
print "i am here"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters

why haha(object).theprint() get wrong output?
 
R

Roy Smith

contro opinion said:
here is my haha class
class haha(object):
def theprint(self):
print "i am here"

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters

why haha(object).theprint() get wrong output?

Please, when asking questions, let us know what version of python you're
using. I'm guessing 2.x?

In any case, the problem is that you defined a class whose constructor
takes no arguments:
class haha(object):
def theprint(self):
print "i am here"

You didn't define an __init__() method, so it inherits the one from the
base class, object.

Then here:

you try to create an instance of your class and give an argument to the
constructor.
 
8

88888 Dihedral

here is my haha  class
class  haha(object):
  def  theprint(self):
    print "i am here"

The definition of a class named haha.
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters

why   haha(object).theprint()  get wrong output?

You don't have to type the base class object.
 
8

88888 Dihedral

here is my haha  class
class  haha(object):
  def  theprint(self):
    print "i am here"

The definition of a class named haha.
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters

why   haha(object).theprint()  get wrong output?

You don't have to type the base class object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top