On Jan 6, 11:10 am, Matimus <mccre...@gmail.com> wrote:

> `nonlocal` should behave just like `global` does. It doesn't support
> that syntax either. So, yes it was intentional. No, there probably is
> no plan to support it in a later release.
>
> Matt

>From my perspective, that's an unfortunate decision and I question the
rationale.  First, nonlocal doesn't behave exactly like global (you
cannot declare a previously undefined variable nonlocal as you can
with global).  Second, the PEP 3104 description explicitly mentions
that Guido favored adding this behavior to global; I would have
preferred that approach to not providing the extended assignment
support for nonlocal.  Third, I believe that it adds some clarity to
the code.  Seeing 'nonlocal x += 1' immediately tells me that I'm
incrementing a variable defined in an outer scope.  Having 'nonlocal
x' on one line and 'x += 1' on another makes it a little less clear.

But I do appreciate the reply!

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

Reply via email to