Why has __new__ been implemented as a static method?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat May 3 11:12:17 EDT 2014
On Sat, 03 May 2014 12:37:24 +0200, Jurko Gospodnetić wrote:
> Hi all.
>
> I was wandering why Python implements its __new__ method as a static
> and not a class method?
Have you read Guido's tutorial on it?
https://www.python.org/download/releases/2.2.3/descrintro
[quote]
Factoid: __new__ is a static method, not a class method. I initially
thought it would have to be a class method, and that's why I added the
classmethod primitive. Unfortunately, with class methods, upcalls don't
work right in this case, so I had to make it a static method with an
explicit class as its first argument.
[end quote]
I'm not entirely sure what he means by "upcalls", but I believe it means
to call the method further up (that is, closer to the base) of the
inheritance tree.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list