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

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

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 c...@zip.com.au 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

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

2012-10-14 Thread Cameron Simpson
On 14Oct2012 18:32, Ian Kelly ian.g.ke...@gmail.com wrote: | On Sun, Oct 14, 2012 at 3:54 PM, Cameron Simpson c...@zip.com.au 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

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 c...@zip.com.au wrote: On 14Oct2012 18:32, Ian Kelly ian.g.ke...@gmail.com 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

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

2012-10-14 Thread Cameron Simpson
On 14Oct2012 19:27, Ian Kelly ian.g.ke...@gmail.com wrote: | On Sun, Oct 14, 2012 at 7:08 PM, Cameron Simpson c...@zip.com.au 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

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. snip However, I can't make my make_file_property function work. I've stripped the code down and it does this: snip Traceback (most recent call last): File foo.py,