Can global variable be passed into Python function?
Jussi Piitulainen <jpiitula at ling.helsinki.fi>:
> In alleged contrast, the observable behaviour of languages that "have
> variables" is the same. This is not considered confusing by the people
> who insist that there are no variables in Python.
But of course there are variables in Python:
By ?frozen? we mean that all local state is retained, including the
current bindings of local variables, [...] (<URL:
The public names defined by a module are determined by checking the
module?s namespace for a variable named __all__ (<URL:
It would be impossible to assign to a global variable without global
However, your point about "observable behavior" is key, and Python users
of all people should get the principle (as it is related to duck
> Python indeed does not pass variables (and this is a relevant), but
> neither do the other languages that "have variables".
Maybe the idea comes from the fact that you can't easily pass a
variable to a function for modification.
Consider this C function:
void make_printable(const char **ref)
*ref = "<NULL>";