Foo.__new__ is what species of method?

Ben Finney ben+python at
Tue Jul 14 07:17:35 CEST 2015

Steven D'Aprano <steve+comp.lang.python at> writes:

> py> class Spam(object):
> ...     def __new__(cls):
> ...             print cls
> ... 
> py> Spam.__new__()  # implicit first arg?
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: __new__() takes exactly 1 argument (0 given)

Thanks, I'm glad I checked before filing a bug report.

Hopefully I'll remember that clear test, when I need to remember which
species it is :-)

 \       “Instead of having ‘answers’ on a math test, they should just |
  `\               call them ‘impressions’, and if you got a different |
_o__)   ‘impression’, so what, can't we all be brothers?” —Jack Handey |
Ben Finney

More information about the Python-list mailing list