Can global variable be passed into Python function?

Marko Rauhamaa marko at
Sat Mar 1 01:11:53 CET 2014

Ben Finney <ben+python at>:

> As has been pointed out to you, the whole point here is that string
> objects often *are not* distinct, despite conceptually having distinct
> cretion in the source.

You know full well that this initialization creates references to
distinct objects:

    class ABC:
        IDLE = "IDLE"

The 5 constants can (and should) be distinguished with the "is"
operator. Using "==" in this case would be slightly misleading.

You could define:

    class ABC:
        IDLE = None
        CONNECTING = 1
        CONNECTED = list
        DISCONNECTING = MyDisconnecting(9)
        DISCONNECTED = float("nan")

without changing the functionality of the state machine (as long as "is"
is used to identify the state).


More information about the Python-list mailing list