[Tutor] global statement?

Haiyang haiyang_yang@hotmail.com
Wed, 15 Aug 2001 15:10:55 +0900


Could anyone please tell me WHY function B can't take globalized dictionary
'a' as a default value?
How can I make it work?

>>> def A():
...          global a
...          a = {}
...          a['happyface']=1
...          a['sadface']=99
...
>>> def B(b=a):
...          for item in b:
...               print b
...
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
NameError: name 'a' is not defined



Thannks...

HY