global declaration from within functions

Aahz Maruch aahz at
Tue Aug 21 18:44:06 CEST 2001

In article <3B7A87D8.6F75B13F at>, Rob Andrews  <rob at> wrote:
>*Learning Python* (pp. 99-105) points out that declaring globals from
>within functions is possible, and shows how. I'm trying to think of
>*why* one might want to declare or modify a global from within a
>A friend who knows quite a bit more than I do about the subject said:
>"That's the first thing about python I've seen that really makes me go
>"yecchhh.".  Global variables have to be declared outside the scope of
>any functions or methods in almost every langauge except Perl."

Side note: global names (I prefer to use "name" instead of "variable")
are not truly global in Python; they are only global within a module
namespace.  The only way to get a truly global name is to hack the
builtins module.
                      --- Aahz  <*>  (Copyright 2001 by aahz at

Hugs and backrubs -- I break Rule 6       
Androgynous poly kinky vanilla queer het Pythonista   

"I now regard a fact as a hypothesis that people don't bother to argue
about anymore."  --John Burn, quoted in Lawrence Wright's _Twins_

More information about the Python-list mailing list