On Mon, 30 May 2011 03:53:24 +1000, Chris Angelico wrote:

> On Sun, May 29, 2011 at 10:47 PM, Steven D'Aprano
> <steve+comp.lang.pyt...@pearwood.info> wrote:
>> If a name is assigned to anywhere in the function, treat it as a local,
>> and look it up in the local namespace. If not found, raise
>> UnboundLocalError.
>>
>>
> Wait wha? I've never seen this... wouldn't it just create it in the
> local namespace?
> 
> Can you give example code that will trigger this error? I'm curious,
> now...

def f():
    print a  # a is not yet defined, i.e. unbound
    a = 1  # this makes a local


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to