Can global variable be passed into Python function?
Marko Rauhamaa
marko at pacujo.net
Sun Mar 2 17:46:49 EST 2014
Michael Torrie <torriem at gmail.com>:
> And one could also set A=1 and B=1 if he was trying to be stupid.
> [...]
> If Mark H wants to use an idiom that isn't conventional, or isn't
> widely used, he is free to do so; I can't see much harm in it. But
> certainly it's not the "normal" way that it's done in Python from what
> I can see.
You might be referring to what I have proposed.
Note that the idiom is in use in some standard python modules
(socket.py, ftplib.py, argparse.py, optparse.py). It is used extensively
in sre_compile.py/sre_constants.py:
ANY = "any"
[...]
AT = "at"
[...]
CALL = "call"
[...]
IN = "in"
elif op is IN:
[...]
elif op is ANY:
[...]
elif op is CALL:
[...]
elif op is AT:
Marko
More information about the Python-list
mailing list