Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'value,': 0.04; 'subject:Python': 0.06; '*not*': 0.07; 'source.': 0.07; 'string': 0.09; 'objects:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'creates': 0.14; '"idle"': 0.16; '"is"': 0.16; 'disconnected': 0.16; 'distinct': 0.16; 'elsewhere.': 0.16; 'finney': 0.16; 'operator.': 0.16; 'other,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reliably': 0.16; 'subject:variable': 0.16; 'pointed': 0.19; 'header:User-Agent:1': 0.23; 'connected': 0.24; 'compare': 0.26; 'references': 0.26; 'defined': 0.27; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'equality': 0.31; 'writes:': 0.31; 'class': 0.32; 'equal': 0.35; 'objects': 0.35; 'idle': 0.36; 'received:com.au': 0.36; 'subject:?': 0.36; 'should': 0.36; 'behind': 0.37; 'so,': 0.37; 'being': 0.38; 'ben': 0.38; 'somebody': 0.38; 'to:addr :python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'subject:Can': 0.60; 'full': 0.61; 'course': 0.61; 'connecting': 0.64; 'afraid': 0.65; 'here': 0.66; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Can global variable be passed into Python function? Date: Sat, 01 Mar 2014 11:50:37 +1100 References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <5f4f5a5f-327a-4616-8235-17ee9e74c488@googlegroups.com> <530fef58$0$11113$c3e8da3@news.astraweb.com> <871tynznpd.fsf@elektro.pacujo.net> <53104798$0$11113$c3e8da3@news.astraweb.com> <87ha7jy2qs.fsf@elektro.pacujo.net> <87k3ceeq0m.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: vmx15867.hosting24.com.au X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:6yQ8xqnsyLQHxd7UsB+GTES0iJM= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393635051 news.xs4all.nl 2868 [2001:888:2000:d::a6]:45115 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67266 Marko Rauhamaa writes: > Ben Finney : > > > As has been pointed out to you, the whole point here is that string > > objects often *are not* distinct, despite conceptually having distinct > > cretion in the source. > > You know full well that this initialization creates references to > distinct objects: > > class ABC: > IDLE = "IDLE" > CONNECTING = "CONNECTING" > CONNECTED = "CONNECTED" > DISCONNECTING = "DISCONNECTING" > DISCONNECTED = "DISCONNECTED" > > The 5 constants can (and should) be distinguished with the "is" > operator. >From each other, of course they're distinct, because they are unequal. They are *not* necessarily distinct from other strings with equal value, defined elsewhere. That's what has been pointed out to you many times. So, either you care about these values being distinct from all others because you want to compare them with ‘is’ (and so strings are a poor choice); or you don't care about that, and you should instead compare these values with the equality operator ‘==’. Either way, don't compare strings with ‘is’. If you want objects you can compare reliably with ‘is’, use some other type. -- \ “Don't be afraid of missing opportunities. Behind every failure | `\ is an opportunity somebody wishes they had missed.” —Jane | _o__) Wagner, via Lily Tomlin | Ben Finney