Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news0.firedrake.org!usenet-its.stanford.edu!usenet.stanford.edu!news.kjsl.com!newsfeed-00.mathworks.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Can global variable be passed into Python function? Date: Fri, 28 Feb 2014 14:20:35 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 32 Message-ID: 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> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1393597235 23275 64.122.56.22 (28 Feb 2014 14:20:35 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 28 Feb 2014 14:20:35 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:67365 On 2014-02-28, Marko Rauhamaa wrote: > Here's a use case for "is" with strings (or ints): > > class Connection: > IDLE = "IDLE" > CONNECTING = "CONNECTING" > CONNECTED = "CONNECTED" > DISCONNECTING = "DISCONNECTING" > DISCONNECTED = "DISCONNECTED" > > def __init__(self): > self.state = IDLE > > def connect(self, address): > ... > self.state = CONNECTING > ... > > def disconnect(self): > ... > if self.state is CONNECTED: > ... I don't really see the point. Why won't '==' work just as well? Are you hoping that 'is' is faster at runtime than '=='? -- Grant Edwards grant.b.edwards Yow! Th' MIND is the Pizza at Palace of th' SOUL gmail.com