Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'instance,': 0.05; 'way:': 0.05; 'python': 0.08; 'dynamically': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'def': 0.13; 'method.': 0.15; 'foo(object):': 0.16; 'mon,': 0.16; 'wrote:': 0.18; '2.x': 0.18; 'detect': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'static': 0.24; 'says': 0.25; "i'm": 0.26; 'bit': 0.28; 'fixed': 0.29; 'pm,': 0.29; 'class': 0.29; 'confused': 0.30; 'oversight': 0.30; 'anyone': 0.31; 'does': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'probably': 0.34; 'someone': 0.34; 'richard': 0.34; 'regular': 0.35; 'url:python': 0.36; 'explain': 0.36; 'received:au': 0.36; '...': 0.36; 'bound': 0.37; 'skip:" 10': 0.37; 'skip:_ 10': 0.37; 'could': 0.37; 'received:org': 0.38; 'url:docs': 0.39; "i'd": 0.39; 'url:org': 0.39; 'should': 0.39; 'to:addr:python.org': 0.40; 'applying': 0.62; 'special': 0.68; 'fredrik': 0.84; 'url:datamodel': 0.84; 'url:reference': 0.84; 'received:110': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lie Ryan Subject: Re: confused about __new__ Date: Tue, 27 Dec 2011 18:47:22 +1100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 110-175-240-90.static.tpgi.com.au User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324972062 news.xs4all.nl 6877 [2001:888:2000:d::a6]:42405 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18016 On 12/27/2011 04:48 PM, Fredrik Tolf wrote: > On Mon, 26 Dec 2011, K. Richard Pixley wrote: >> I don't understand. Can anyone explain? > > I'm also a bit confused about __new__. I'd very much appreciate it if > someone could explain the following aspects of it: > > * The manual () says > that __new__ is "a static method (special-cased so you need not declare > it as such)". What does "special-cased" mean? Apparently, for > instance, in OP's case, Python did not automatically detect that it > should not be bound as a method. If you declare new in the regular way: class Foo(object): def __new__(cls): ... Python would create __new__ as a static method even without applying the staticmethod decorator; that python does not detect to special case __new__ when it is added dynamically is probably an oversight in Python 2.x that was fixed in Python 3.x.