Variable Scope

Peter Hansen peter at engcorp.com
Fri Jan 9 14:47:36 EST 2004


Jens Thiede wrote:
> 
> In the following terminal; could someone inform me as to why it is
> posible to print a global variable without having to declare it using
> global. This has affected some source of mine, and allows you to
> modify a global in a local scope *without* the global keyword, for
> instance, you can append to a global list, but *not* assign it a new
> value, for then, you create a new local variable. -- Why.

Have you read http://www.python.org/doc/faq/programming.html#how-do-you-set-a-global-variable-in-a-function ?

It should clarify some of these issues.  If it does not, please let us
know what's still unclear and the FAQ can be improved.

-Peter



More information about the Python-list mailing list