the class problem
timr at probo.com
Tue Jan 1 20:31:14 CET 2013
contro opinion <contropinion at gmail.com> wrote:
>here is my haha class
> def theprint(self):
> print "i am here"
>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?
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 probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list