global variables and local functions.

Erik Max Francis max at alcyone.com
Fri Aug 30 01:02:38 EDT 2002


Inyeol Lee wrote:

> 'global' keyword is not required when appending something to a global
> list
> in local scope, since there's no assignment with list.append(). For
> example,

Right, it's only required when names are being rebound, not merely when
objects are being changed.  The style that I generally adhere to is
using a global statement whenever I'm referencing (whether rebinding or
not) a global variable.  Since I tend not to use globals all that much
anyway, it helps set them off better.  It also means you don't have to
consider the precise rule when the global statement is needed; if you
use it wherever globals are involved the details of the rule are
unimportant.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.



More information about the Python-list mailing list