|
|
Subscribe / Log in / New account

Discussing PEP 572

Discussing PEP 572

Posted Mar 16, 2018 10:59 UTC (Fri) by jag (subscriber, #3766)
In reply to: Discussing PEP 572 by nybble41
Parent article: Discussing PEP 572

Out of these three:


  stuff = [ (lambda y: [y, y])(f(x)) for x in range(5) ]

  stuff = [ [(f(x) as y), y] for x in range(5) ]

  stuff = [ f(x) as y in [y, y] for x in range(5) ]

I find the third line the easiest to read and understand, though the "in" bit should be allowed to be omitted:

  #while (sock.read() as data in data):
  while (sock.read() as data):
      print("Received data:", data)

(Bike-shedding is fun!)


to post comments

Discussing PEP 572

Posted Mar 22, 2018 17:13 UTC (Thu) by welinder (guest, #4699) [Link] (1 responses)

Is there an official rule that things in Python have to look different than the
same thing in other languages?

It's just a let-expression, so calling it "let" would be the obvious thing.

Discussing PEP 572

Posted Mar 22, 2018 17:59 UTC (Thu) by anselm (subscriber, #2796) [Link]

Obvious perhaps, but the people in charge of Python are understandably reluctant to introduce new keywords, which is always a problem for backwards compatibility.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds