father class name
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Dec 31 22:24:30 EST 2012
On Mon, 31 Dec 2012 20:23:44 +1100, Ben Finney wrote:
> Chris Rebert <clp2 at rebertia.com> writes:
>
>> By contrast, in the first part of the *expression*
>> `haha(object).theprint()`, you passed an argument (namely, `object`).
>> Since __init__() wasn't expecting any arguments whatsoever, you
>> therefore got an error.
>
> Why is everyone talking about the initialiser, ‘__init__’?
>
> When:
>
>> >>>> haha(object).theprint()
>> > Traceback (most recent call last):
>> > File "<stdin>", line 1, in <module>
>> > TypeError: object.__new__() takes no parameters
>
> The error is talking about the constructor, ‘__new__’.
Good point.
I think we do a disservice to newbies when we (inadvertently) discourage
them from reading the tracebacks generated by an error. The traceback
clearly talks about a __new__ method.
I don't believe that talking about the constructor __new__ is so
complicated that we should ignore the actual error and go of on a wild-
goose chase about the initialiser __init__, especially since adding an
__init__ method to the class *won't solve the problem*.
Sorry Chris, I think you dropped the ball on this one and gave an overtly
misleading answer :-(
--
Steven
More information about the Python-list
mailing list