[Tutor] Global Variables
bob gailer
bgailer at gmail.com
Sat Nov 21 23:56:26 CET 2009
Alan Gauld wrote:
>>
>>
>> dname()
>> ########
>> def dname():
>> global nl
>
> This looks for or creates an nl in your module.
Beg to differ- global will not create it.
def f():global a
...
>>> a
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'a' is not defined
What it does is alert the compiler that assignment to the variable will
make it global.
--
Bob Gailer
Chapel Hill NC
919-636-4239
More information about the Tutor
mailing list