[Python-Dev] Re: For-If syntax
Questions like this are best asked on python-ideas. Specifically, though, you can get the same result with: for x in (n for n in y if n.is_some_thing): without requiring new syntax. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@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/LBI4JNJ6CIG5VDRVJ6EYV52IIWV5AXUG/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: For-If syntax
On 5/1/20 9:19 AM, silverback...@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-le...@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 ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@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/T3VQGGAHYR4AOKMVPL5NDTAV2GB6BIAH/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: For-If syntax
We seem to be, once again, rehashing about this. For example, I proposed this in 2017, which was not the first time: https://mail.python.org/archives/list/python-id...@python.org/thread/GFZFJAI4WGFYFFVQTF7DORHMY7F45XZZ/ (Gary's suggestion, and (counter) counter points to it are in the linked discussion) Would it maybe be time for someone to write a PEP for this (if they can be found), so it can then be rejected (or not)? I think there is no bikeshedding to be done on the idea, though in terms of parsing there might be (though as I mentioned in that thread, there should be no difference to generator expression parsing). On Fri, 1 May 2020 at 19:52, Gary Herron wrote: > > On 5/1/20 9:19 AM, silverback...@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.orghttps://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 > > ___ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@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/T3VQGGAHYR4AOKMVPL5NDTAV2GB6BIAH/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@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/SBEKOAFBUNVFXR5UXCSFF6HPEE4GEE6O/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: For-If syntax
Thanks, this is what I was looking for and couldn't find. I'm glad it is something that's been considered and debated before. I'm not sure why I couldn't find it or anything like it, but I guess the syntax is just a needle in a haystack. Em On Sat, May 2, 2020 at 7:42 AM Henk-Jaap Wagenaar < wagenaarhenkj...@gmail.com> wrote: > We seem to be, once again, rehashing about this. For example, I proposed > this in 2017, which was not the first time: > > > https://mail.python.org/archives/list/python-id...@python.org/thread/GFZFJAI4WGFYFFVQTF7DORHMY7F45XZZ/ > > (Gary's suggestion, and (counter) counter points to it are in the linked > discussion) > > Would it maybe be time for someone to write a PEP for this (if they can be > found), so it can then be rejected (or not)? > > I think there is no bikeshedding to be done on the idea, though in terms > of parsing there might be (though as I mentioned in that thread, there > should be no difference to generator expression parsing). > > On Fri, 1 May 2020 at 19:52, Gary Herron wrote: > >> >> On 5/1/20 9:19 AM, silverback...@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.orghttps://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 >> >> ___ >> Python-Dev mailing list -- python-dev@python.org >> To unsubscribe send an email to python-dev-le...@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/T3VQGGAHYR4AOKMVPL5NDTAV2GB6BIAH/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > ___ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@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/SBEKOAFBUNVFXR5UXCSFF6HPEE4GEE6O/ > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@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/7E4CK5GBA2F4WLVECHOCJFY54L5WRCLI/ Code of Conduct: http://python.org/psf/codeofconduct/