On Thu, Apr 19, 2018 at 6:26 AM, Barry Warsaw <ba...@python.org> wrote:
> On Apr 18, 2018, at 11:17, Chris Angelico <ros...@gmail.com> wrote:
>
>> At the moment, it isn't aware of 'del’.
>
> I don’t know if it’s relevant to the current discussion, but don’t forget 
> about implicit dels:
>
> def foo():
>     x = 1
>     try:
>         1/0
>     except ZeroDivisionError as x:
>         pass
>     print(x)
>
>
> This is one of my favorite Python oddities because it always makes me look 
> like a genius when I diagnose it. :)

Heh, yeah. My intention is to ignore that altogether. The general
policy in Python is "if ever it MIGHT be assigned to, it belongs to
that scope" (so even "if 0: x = 1" will mark x as local), so sticking
to that would mean treating x as local regardless of the try/except.

(On an unrelated subject, I'm keeping the "sublocal scope" concept
from the original PEP on ice. It might be worth implementing exception
name binding with a sublocal name. But that's for a completely
separate PEP.)

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to