[Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

Chris Angelico rosuav at gmail.com
Fri Mar 2 11:04:17 EST 2018


On Sat, Mar 3, 2018 at 1:53 AM, Rhodri James <rhodri at kynesim.co.uk> wrote:
> On 02/03/18 11:43, Chris Angelico wrote:
>>
>> After dozens of posts and a wide variety of useful opinions and
>> concerns being raised, here is the newest version of PEP 572 for your
>> debating pleasure.
>
>
> I haven't said this yet, so thanks Chris for putting this all together. Even
> if the result is a rejected PEP, at least we have everything in one place.

No problem. And I agree, a rejected PEP is still a successful result here.

(Am I going to get a reputation for captaining dead PEPs?)

>>      # Compound statements usually enclose everything...
>>      if (re.match(...) as m):
>>          print(m.groups(0))
>>      print(m) # NameError
>
>
> This (and the equivalent in while loops) is the big win in the PEP, in my
> opinion.  The number of ugly loops I've had to write in Python because I
> can't write "while (something_to_do() as event):"...  +1 on this.
>
>>      # Using a statement-local name
>>      stuff = [[(f(x) as y), x/y] for x in range(5)]
>
>
> As Paul said, the asymmetry of this bothers me a lot.  It doesn't read
> naturally to me. -1 on this.

Interesting. I fully expected to get a lot more backlash for the
if/while usage, but a number of people are saying that that's the only
(or the biggest) part of this proposal that they like.

ChrisA


More information about the Python-ideas mailing list