Can global variable be passed into Python function?
Chris Angelico <rosuav at gmail.com>:
> On Fri, Feb 28, 2014 at 10:30 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> Chris Angelico <rosuav at gmail.com>:
>> a.state = a.INIT
> In theory, yes. If that's all people will ever do, then you can safely
> use == to check. Why are you using is?
The main reason to use "is" is to indicate that the object is a sentinel
object whose identity is what is meaningful, not the content. Using ==
would work but would give some poor soul the idea that the state
variable could hold any imaginable string.
The implementation should be able to change the state objects to any
(distinct) objects at all (say, the new enums, or ints, or some more
elaborate class instances) without any changes in the code.