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


Groups > comp.lang.python > #10487

Re: NoneType and new instances

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 <ethan@stoneleaf.us>
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 <ethan@stoneleaf.us>
User-Agent Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version 1.0
To Ben Finney <ben+python@benfinney.id.au>
Subject Re: NoneType and new instances
References <mailman.1575.1311866659.1164.python-list@python.org> <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1597.1311891054.1164.python-list@python.org> (permalink)
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

Show key headers only | View raw


Ben Finney wrote:
> Ethan Furman <ethan@stoneleaf.us> 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~

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


Thread

NoneType and new instances Ethan Furman <ethan@stoneleaf.us> - 2011-07-28 08:39 -0700
  Re: NoneType and new instances Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-28 11:34 -0400
  Re: NoneType and new instances Ben Finney <ben+python@benfinney.id.au> - 2011-07-29 07:46 +1000
    Re: NoneType and new instances Ethan Furman <ethan@stoneleaf.us> - 2011-07-28 15:26 -0700
      Re: NoneType and new instances Ben Finney <ben+python@benfinney.id.au> - 2011-07-29 09:52 +1000
  Re: NoneType and new instances Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-29 11:16 +1000
    Re: NoneType and new instances Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-07-30 14:50 +1200
      Re: NoneType and new instances Terry Reedy <tjreedy@udel.edu> - 2011-07-30 09:35 -0400
      Re: NoneType and new instances python@bdurham.com - 2011-07-30 11:43 -0400
  Re: NoneType and new instances "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-07-30 09:39 -0700
    Re: NoneType and new instances Terry Reedy <tjreedy@udel.edu> - 2011-07-30 23:34 -0400
      Re: NoneType and new instances Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-31 14:28 +1000

csiph-web