the class problem

Tim Roberts timr at
Tue Jan 1 20:31:14 CET 2013

contro opinion <contropinion at> wrote:
>here is my haha  class
>class  haha(object):
>  def  theprint(self):
>    print "i am here"
>>>> haha().theprint()
>i am here
>>>> haha(object).theprint()
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>TypeError: object.__new__() takes no parameters
>why   haha(object).theprint()  get wrong output?

It doesn't -- that's the right output.  What did you expect it to do?

The line "class haha(object)" says that "haha" is a class that happens to
derive from the "object" base class.  The class is still simply called
"haha", and to create an instance of the class "haha", you write "haha()".
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list