Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'interpreter': 0.05; 'disagree': 0.07; 'python': 0.08; 'sure,': 0.09; 'invoking': 0.16; 'singleton': 0.16; 'workaround': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; "haven't": 0.20; 'trying': 0.21; 'dec': 0.22; "doesn't": 0.22; 'header:In- Reply-To:1': 0.22; 'locking': 0.23; '\xa0if': 0.23; 'cc:2**0': 0.24; 'creating': 0.25; 'demonstrate': 0.25; 'guess': 0.26; 'classes': 0.26; 'message-id:@mail.gmail.com': 0.28; '27,': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'class': 0.29; 'really,': 0.30; 'user.': 0.31; 'certainly': 0.32; 'pointing': 0.32; 'tue,': 0.32; "can't": 0.32; 'actually': 0.33; 'it.': 0.34; 'force': 0.34; 'richard': 0.34; 'received:74.125.82': 0.35; 'apply': 0.35; 'unless': 0.35; 'convenient': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'enough': 0.38; 'doing': 0.38; 'possible.': 0.39; 'should': 0.39; 'being': 0.39; "it's": 0.40; '2011': 0.61; 'ever': 0.65; 'protection': 0.67; 'doing.': 0.73; 'protecting': 0.73; 'claim': 0.76; 'messed': 0.84; 'to:addr:rich': 0.84; 'hostile': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=f78GBGgl2W/gg6iLlX+rf32oBfBagcVC8aoNbsNsSpQ=; b=cpGBsF+qFl65m/PYI4VwPKFRPHM760vhVe4H36Fct6haScqf30vA/TCx3+83rrK2Nh JF0xTpM7H/RBIFPzarDu/eFmODU9exsIXKu7sHJ65bnzRjwPXfXACJc+ugXd0jF9lqt0 Uem2CX/GhWhwsW2jUQpjqm8Q4B+FvtnLNs6TE= MIME-Version: 1.0 In-Reply-To: <5wrKq.39032$mJ.10777@newsfe10.iad> References: <4EFA2B0E.2000506@noir.com> <5wrKq.39032$mJ.10777@newsfe10.iad> From: Ian Kelly Date: Tue, 27 Dec 2011 15:43:29 -0700 Subject: Re: confused about __new__ To: K Richard Pixley Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325025847 news.xs4all.nl 6867 [2001:888:2000:d::a6]:51324 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18069 On Tue, Dec 27, 2011 at 3:19 PM, K Richard Pixley wrote: > Are you trying to demonstrate that I haven't prevented you from > instantiating Foo? =A0If so, then I will cede that point. =A0I certainly = don't > know enough about python internals just now to even claim to be capable o= f > protecting a class from a hostile user. =A0My guess is that short of a > privileged/unprivileged split, or castrating the interpreter and locking = you > into it, such a protection would not be possible. Yes, that was the point. I certainly don't think that anybody should ever be creating class instances by directly invoking object.__new__ unless they really, really know what they are doing. I was just pointing out that I don't think it's actually possible to prevent classes from being instantiated. > My point was that I can indeed intercept common and convenient usage to > create a lovely singleton semantic. =A0I can't force you to use it. (Nor = do I > have any motivation to so do.) Sure, I don't disagree with that. And the object.__new__ workaround is a general point that doesn't apply only to singletons. Any class that customizes its instantiation process can be messed up by doing that.