scopes? (is: I don't get it ...)

Axel Bock news-and-lists at the-me.de
Thu May 29 14:28:57 EDT 2003


Am Thu, 29 May 2003 10:21:00 -0700 schrieb djw:

> In order to assign to a global in a funtion, you must use the global
> statement, otherwise Python will assume you are assigning to a local.
> That's the way I understand it, anyway.
> 
> test.py:
> t1 = []
> t2 = 0
> def testme():
>         global t2
>         print t1
>         print t2
>         t2+=1
> 
> 
> /d/

whew, yes, thanks all of you! this helps ... ! :-)
(although i still find it confusing that it prints without even warning
... )


greetings, 

		Axel.




More information about the Python-list mailing list