Can global variable be passed into Python function?

Marko Rauhamaa marko at pacujo.net
Fri Feb 28 06:30:16 EST 2014


Chris Angelico <rosuav at gmail.com>:

> String literals will often be interned if they look like (especially,
> if they *are*) identifiers, so if you want to prevent other strings
> from happening to match, you can't trust 'is'.
>
> [...]
>
> If you're using strings as state values, you should be using == to
> compare them. Nothing else is safe.

You didn't quite understand the use case. You would never ever do things
like:

> >>> a.state="<<INIT>>"

You'd only refer to the state names symbolically:

   a.state = a.INIT


Marko



More information about the Python-list mailing list