Why has __new__ been implemented as a static method?
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sat May 3 19:21:53 EDT 2014
Steven D'Aprano wrote:
> 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.
I think it means this:
def __new__(cls):
MyBaseClass.__new__(cls)
which wouldn't work with a class method, because
MyBaseClass.__new__ would give a *bound* method
rather than an unbound one.
Python 3's version of super() seems to work with
class methods, but Python 2's doesn't (or at least
I couldn't get it to work in a brief test). Also,
I don't think super() existed at all when __new__
was invented.
--
Greg
More information about the Python-list
mailing list