Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 14Oct2012 19:27, Ian Kelly wrote: | On Sun, Oct 14, 2012 at 7:08 PM, Cameron Simpson wrote: | > Is attr_name omitted from locals() in made_file_property _because_ I | > have an assignment statement? | | Yes. Syntactically, a variable is treated as local to a function if | it is assigned to s

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Ian Kelly
On Sun, Oct 14, 2012 at 7:08 PM, Cameron Simpson wrote: > On 14Oct2012 18:32, Ian Kelly wrote: > | 'attr_name' is not in locals because while it's a local variable, it > | has not been assigned to yet. It has no value and an attempt to > | reference it at that point would result in an UnboundLoc

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 14Oct2012 18:32, Ian Kelly wrote: | On Sun, Oct 14, 2012 at 3:54 PM, Cameron Simpson wrote: | > | You assign to it, but there's no nonlocal declaration, so Python thinks | > | it's a local var, hence your error. | > | > But 'unset_object' is in locals(). Why one and not the other? | > Obvious

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Ian Kelly
On Sun, Oct 14, 2012 at 3:54 PM, Cameron Simpson wrote: > | You assign to it, but there's no nonlocal declaration, so Python thinks > | it's a local var, hence your error. > > But 'unset_object' is in locals(). Why one and not the other? > Obviously there's something about closures here I'm missi

Re: trouble with nested closures: one of my variables is missing...

2012-10-14 Thread Cameron Simpson
On 13Oct2012 22:07, Chris Rebert wrote: | On Saturday, October 13, 2012, Cameron Simpson wrote: | > I'm having some trouble with closures when defining a decorator. | | | > However, I can't make my make_file_property function work. I've stripped | > the code down and it does this: | | | > Tr

Re: trouble with nested closures: one of my variables is missing...

2012-10-13 Thread Chris Rebert
On Saturday, October 13, 2012, Cameron Simpson wrote: > I'm having some trouble with closures when defining a decorator. > However, I can't make my make_file_property function work. I've stripped > the code down and it does this: > Traceback (most recent call last): > File "foo.py", li