Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70905

Re: Why has __new__ been implemented as a static method?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Gregory Ewing <greg.ewing@canterbury.ac.nz>
Newsgroups comp.lang.python
Subject Re: Why has __new__ been implemented as a static method?
Date Sun, 04 May 2014 11:21:53 +1200
Lines 22
Message-ID <bslc0jFf9idU1@mid.individual.net> (permalink)
References <mailman.9665.1399113463.18130.python-list@python.org> <53650751$0$29965$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net HTlgcMft/yMcLEBRl++JRQnioAtJBJsB6bed8Q19VTko3Y6WTC
Cancel-Lock sha1:oxX1/gLo3TIPt4+wt283ldl6U3Q=
User-Agent Mozilla Thunderbird 1.0.5 (Macintosh/20050711)
X-Accept-Language en-us, en
In-Reply-To <53650751$0$29965$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:70905

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why has __new__ been implemented as a static method? Jurko Gospodnetić <jurko.gospodnetic@pke.hr> - 2014-05-03 12:37 +0200
  Re: Why has __new__ been implemented as a static method? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-03 15:12 +0000
    Re: Why has __new__ been implemented as a static method? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-05-04 11:21 +1200
      Re: Why has __new__ been implemented as a static method? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-04 03:37 +0000
        Re: Why has __new__ been implemented as a static method? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-05-04 20:03 +1200
          Re: Why has __new__ been implemented as a static method? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-04 14:16 +0000
            Re: Why has __new__ been implemented as a static method? Rotwang <sg552@hotmail.co.uk> - 2014-05-04 17:24 +0100
            Re: Why has __new__ been implemented as a static method? Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-04 11:05 -0600

csiph-web