Can global variable be passed into Python function?

Steven D'Aprano steve+comp.lang.python at
Sat Mar 1 01:58:34 CET 2014

On Sat, 01 Mar 2014 02:11:53 +0200, Marko Rauhamaa wrote:

> 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.

I disagree. You are focusing on identity, but identity is (usually) not 
important. That's an implementation detail.

What we have here is the curse of the singleton design anti-pattern:

Since the symbols IDLE, CONNECTING etc. don't have state apart from their 
name, whether there is one or a million and one instances is irrelevant.


More information about the Python-list mailing list