Can global variable be passed into Python function?

Ben Finney ben+python at
Sat Mar 1 11:48:40 CET 2014

Marko Rauhamaa <marko at> writes:

> Ben Finney <ben+python at>:
> > Since you don't care about identity, only that the objects have
> > different values, you should be comparing for equality with ‘==’.
> Ok, one last attempt.
> I need *identifiers*.

And, as you've realised, without an Enum pattern you have the option of
using string *values* — because it's the values you want to see in error
message output.

The *identity* of the values doesn't matter. Any string of the given
value will work fine.

So don't fool the reader into thinking you actually care about object
identity; don't use ‘is’ for comparing these values. Use ‘==’, since
that's all that matters for getting a value that will work fine.

> The same program still works (and still uses "is" for identity tests,
> mind you).

You have provided no justification for using an identity test. It
confuses the matter by pretending you care about object identity, when
you *do not* as evidenced by all your arguments so far.

The equality operator ‘==’ is clearer for your purpose, and less

 \      “[Entrenched media corporations will] maintain the status quo, |
  `\       or die trying. Either is better than actually WORKING for a |
_o__)                  living.” —, 2007-11-12 |
Ben Finney

More information about the Python-list mailing list