Chris Angelico <ros...@gmail.com>:

> On Fri, Feb 28, 2014 at 10:30 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> Chris Angelico <ros...@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.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to