Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'instance': 0.05; ':-)': 0.06; 'disagree': 0.07; 'bool': 0.09; 'false,': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'likewise,': 0.09; 'message- id:@stoneleaf.us': 0.09; 'none.': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'broken': 0.12; 'exception': 0.12; 'thorough': 0.13; 'wrote:': 0.15; 'duty.': 0.16; 'ellipsis': 0.16; 'finney': 0.16; 'instances.': 0.16; 'okay,': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'object,': 0.16; 'cc:addr:python-list': 0.16; 'question.': 0.16; 'exists': 0.19; 'true,': 0.19; 'slightly': 0.19; 'cc:2**0': 0.21; "aren't": 0.22; 'pointed': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'relaxed': 0.23; 'writes:': 0.25; 'raise': 0.28; 'object': 0.30; 'cc:addr:python.org': 0.30; 'definition': 0.30; 'exists,': 0.30; 'yet': 0.30; 'unable': 0.31; 'answers': 0.32; 'cases': 0.32; 'value.': 0.32; 'break': 0.33; 'header:User-Agent:1': 0.34; 'there': 0.34; 'nobody': 0.34; 'rule': 0.34; 'quite': 0.34; 'none': 0.35; 'subject:new': 0.36; '(to': 0.37; 'but': 0.37; 'subject:: ': 0.38; 'returning': 0.38; 'think': 0.38; 'two': 0.38; 'case': 0.39; 'should': 0.39; 'either': 0.39; 'your': 0.60; 'easily': 0.61; 'received:websitewelcome.com': 0.65; 'ever': 0.65; 'fulfill': 0.67; 'received:184': 0.67; 'violation': 0.67; 'special': 0.67; 'received:69.56': 0.73; 'introduced.': 0.84; 'received:69.56.224': 0.84; 'received:69.56.224.20': 0.84; 'them:': 0.84; 'false;': 0.91; 'received:gateway02.websitewelcome.com': 0.93 Date: Thu, 28 Jul 2011 15:26:21 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Ben Finney Subject: Re: NoneType and new instances References: <87hb66nkn5.fsf@benfinney.id.au> In-Reply-To: <87hb66nkn5.fsf@benfinney.id.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:2418 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311891054 news.xs4all.nl 23851 [2001:888:2000:d::a6]:34895 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10487 Ben Finney wrote: > Ethan Furman writes: > >> Why is NoneType unable to produce a None instance? I realise that None >> is a singleton > > That answers your question. Because None is a singleton, the job of its > type is to make sure there are no other instances. Which it can do quite easily by returning the single instance of None -- it is not necessary to raise an exception to fulfill its duty. >> but so are True and False, and bool is able to handle returning them: > > Well, they don't meet the definition of a singleton, because there are > two instances of ‘bool’ :-) Okay, a slightly relaxed definition of singleton, since there is only ever one instance with the value of True, or the value of False; likewise, there is only ever one instance with the value of None. >> This feels like a violation of 'Special cases aren't special enough to >> break the rules.' > > In the case of ‘bool’, the rule was broken before being introduced. I think we disagree on what the rule is. I see it as "Return an instance if you can." Nobody has yet pointed out a good reason on why NoneType, NotImplementedType, and ellipsis (to be thorough ;) cannot or should not return the single instance that exists, when every other built-in will return either a new object, or the single object that exists for that value. ~Ethan~