Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31269 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2012-10-14 18:32 -0600 |
| Last post | 2012-10-14 18:32 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: trouble with nested closures: one of my variables is missing... Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-14 18:32 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2012-10-14 18:32 -0600 |
| Subject | Re: trouble with nested closures: one of my variables is missing... |
| Message-ID | <mailman.2186.1350261154.27098.python-list@python.org> |
On Sun, Oct 14, 2012 at 3:54 PM, Cameron Simpson <cs@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 here I'm missing. 'unset_object' is in locals because it's a free variable and those are included in locals(), and it has a value. '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 UnboundLocalError.
Back to top | Article view | comp.lang.python
csiph-web