Can global variable be passed into Python function?

Marko Rauhamaa marko at
Fri Feb 21 11:10:56 CET 2014

Jussi Piitulainen <jpiitula at>:

> 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

etc etc.

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)
       if (!*ref)
           *ref = "<NULL>";

which allows:



More information about the Python-list mailing list