Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'none:': 0.05; 'that?': 0.05; 'raises': 0.07; 'bool': 0.09; 'instance.': 0.09; 'subject:None': 0.09; 'typeerror:': 0.09; 'subject:type': 0.16; 'wrote:': 0.17; 'instance': 0.17; '"",': 0.22; 'class.': 0.23; 'this:': 0.23; 'second': 0.24; 'allows': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; "d'aprano": 0.29; 'obj': 0.29; 'steven': 0.29; 'error': 0.30; 'file': 0.32; 'instances': 0.33; 'traceback': 0.33; 'to:addr :python-list': 0.33; 'useful': 0.36; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'received:204': 0.72 Date: Thu, 16 Aug 2012 14:54:03 +0200 From: Laszlo Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: type(None)() References: <502cebf4$0$6905$e4fe514c@news2.news.xs4all.nl> In-Reply-To: <502cebf4$0$6905$e4fe514c@news2.news.xs4all.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345122462 news.xs4all.nl 6983 [2001:888:2000:d::a6]:46801 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27160 On 2012-08-16 14:47, Hans Mulder wrote: > On 8/08/12 04:14:01, Steven D'Aprano wrote: >> NoneType raises an error if you try to create a second instance. bool >> just returns one of the two singletons (doubletons?) again. >> >> py> type(None)() >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: cannot create 'NoneType' instances > Why is that? Because None is a singleton. It is the only instance of its class. This is very useful because it allows you to write conditions like this: if obj is None: do_something()