Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'that?': 0.05; 'raises': 0.07; 'type,': 0.07; 'bool': 0.09; 'instance.': 0.09; 'subject:None': 0.09; 'typeerror:': 0.09; 'aug': 0.13; 'subject:type': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'thu,': 0.17; 'error.': 0.21; '"",': 0.22; 'int,': 0.22; 'simpler': 0.22; 'raise': 0.24; 'second': 0.24; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; "d'aprano": 0.29; 'steven': 0.29; 'str': 0.29; 'that.': 0.30; 'unlike': 0.30; 'error': 0.30; 'file': 0.32; 'instances': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'built-in': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=dbSQLNq+mtX1K9Hg7/S3jbTbjX07t1kMTGRQGkpdfvU=; b=e24jsWW5xqLiYs4v8ULc7vssx4MmFSwoEPqOoX/UhjruHQUGG330L22ii7rn7Lrc2w 3E8UJ7ZHitvKNJnBRt6eEDE0n/sYO1qJ7Ww2uKnkWMqoKs3THvxOoiP6sV8rgsNgEhch PYm3ZiHfzbmmjbNIKM/wXRB5TW/KY7QO2sMPX7ax1PGvc11h06sZ9zmkbl6x8YkXbvDX JGClkapegiO5buHopc0J+vVLCgCiTE6b8oQ1ZUNBqy2vdllrVDQI3DaRbYrAEZxO7INM LdRa84ng17G0fgwecOpn4lMSN9K9m8n3oR66aK2WXn9j4QS0qjxDmDjjaeU8fY02/4dP wL6Q== MIME-Version: 1.0 In-Reply-To: <502cebf4$0$6905$e4fe514c@news2.news.xs4all.nl> References: <502cebf4$0$6905$e4fe514c@news2.news.xs4all.nl> From: Ian Kelly Date: Thu, 16 Aug 2012 07:56:03 -0600 Subject: Re: type(None)() To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 1345125395 news.xs4all.nl 6897 [2001:888:2000:d::a6]:58442 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27163 On Thu, Aug 16, 2012 at 6:47 AM, 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? > > Why doesn't it just return an existing instance of the type, > like bool, int, str and other built-in non-mutable types do? Because unlike those other types there is no use case for that. It's simpler to raise an error.