This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jhylton
Recipients amaury.forgeotdarc, benjamin.peterson, cmcqueen1975, gvanrossum, jhylton, pje, rhettinger, terry.reedy
Date 2010-02-22.23:51:08
SpamBayes Score 9.033885e-13
Marked as misclassified No
Message-id <e8bf7a531002221551q1d65db03o84a6a9b63f908797@mail.gmail.com>
In-reply-to <1266880254.52.0.863061255282.issue4617@psf.upfronthosting.co.za>
Content
On Mon, Feb 22, 2010 at 6:10 PM, Guido van Rossum
<report@bugs.python.org> wrote:
>
> Guido van Rossum <guido@python.org> added the comment:
>
> All examples so far (*) have to do with our inability to have properly nested blocks. If we did, I'd make the except clause a block, and I'd issue a syntax warning or error if a nested block shadowed a variable referenced outside it. Ditto for generator expressions and comprehensions.

There's no reason we couldn't revise the language spec to explain that
except clauses and comprehensions are block statements, i.e.
statements that introduce a new block.  For the except case, there
would be some weird effects.

y = 10
try:
  ...
except SomeError as err:
  y = 12
print y  # prints 10

In the example above, y would be a local variable in the scope of the
except handler that shadows the local variable in the block that
contains the try/except.  It might be confusing that you couldn't
assign to a local variable in the except handler without using a
nonlocal statement.

> As long as we don't have nested blocks, I think it's okay to see the limitation on (implicit or explicit) "del" of a cell variable as a compiler deficiency and fix that deficiency.

The general request here is to remove all the SyntaxErrors about
deleting cell variables, right?  Instead, you'd get a NameError at
runtime saying that the variable is currently undefined.  You'd want
that change regardless of whether we change the language as described
above.

hoping-for-some-bdfl-pronouncements-ly y'rs,
Jeremy

> __________
> (*) However there's also this example:
>
>>>> def f():
> ...  try: 1/0
> ...  except Exception as a:
> ...   def g(): return a
> ...   return g
> ...
> SyntaxError: can not delete variable 'a' referenced in nested scope
>>>>
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue4617>
> _______________________________________
>
History
Date User Action Args
2010-02-22 23:51:10jhyltonsetrecipients: + jhylton, gvanrossum, rhettinger, terry.reedy, pje, amaury.forgeotdarc, benjamin.peterson, cmcqueen1975
2010-02-22 23:51:09jhyltonlinkissue4617 messages
2010-02-22 23:51:08jhyltoncreate