Boris Mok <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I'm doing a function which needs return an arrary -- or more specially a 
> dictionary data type.
> I have a sample like this
> 
> def AFC():
>   v["a"] = 1
>   return v
> 
> v = AFC()
> print v["a"]
> 
> with error
> NameError: global name 'v' is not defined
> 
> how do I go about it?
> 
At some point you have to initialise v to a dictionary, Python isn't going 
to guess for you. e.g.

def AFC():
  v = {}
  v["a"] = 1
  return v
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to