On 5/1/20 9:19 AM, silverbacknet@gmail.com wrote:
I hope this isn't too noobish, nothing on the list comes up in Google, but I'm curious why the construct

for x in y if x.is_some_thing:
  # do a thing

But this is probably clearer (and has the same syntax):

for x in y:
  if x.is_some_thing:
    # do a thing


Cramming two separate thoughts onto a single line is probably *not* clearer.



isn't legal. That seems a very Pythonic symmetry with lambdas. The equivalent syntax required right now is,

for x in [x for x in y if x.is_some_thing]:
  # do a thing

Of course there's more flexibility in the full syntax, but is there any interest in the simpler, more performant one-line syntax?

Em

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/VHFUQFEF3TCI6LHLBAUEKMFM2A6V3CQO/
Code of Conduct: http://python.org/psf/codeofconduct/
-- 
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418