Can global variable be passed into Python function?
invalid at invalid.invalid
Fri Feb 28 15:20:35 CET 2014
On 2014-02-28, Marko Rauhamaa <marko at pacujo.net> 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
More information about the Python-list