Can global variable be passed into Python function?

Mark Lawrence breamoreboy at
Sun Mar 2 17:53:06 CET 2014

On 02/03/2014 16:23, Chris Angelico wrote:
> A switch block that works with constants and equality *can* be turned
> into a dict. If the constants are hashable, use them as the keys
> directly; if they're not hashable and/or you want to use object
> identity as the criterion (effectively like using 'is' rather than
> '==' for your case statements), use id(x) as the keys, and make sure
> you have other references to the objects. Then it'll be fine as a
> straight-up dict.
> If the switch block uses inequalities, then it suffers from the same
> problem as the try/except block - it's inherently ordered, in case
> (pun intended) there's a switched-on value that matches more than one.
> (You could possibly optimize the int case, but that would be way WAY
> too specific for a generic language structure.)
> ChrisA

You clearly don't get my point.  I *DON'T* want to use stupid constants 
and stupid equalities, I want to use identities.  I *DON'T* want to use 
stupid ==, I want to use 'is'.  I *DON'T* care how many people with 
years of experience of Python tell me that this is the wrong thing to 
do, that is how I am going to do it.  So, for the final time of asking, 
how do I do the above with, and only with, the identity, even if you 
stupidly keep on trying to tell me that this is wrong?

My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

This email is free from viruses and malware because avast! Antivirus protection is active.

More information about the Python-list mailing list