I really am shocked by how many people seem to have broken ENTER keys on their keyboards.
Let's just keep Python readable rather than see how much we can cram on a line. On Wed, Mar 2, 2022, 2:56 PM Jeremiah Paige <ucod...@gmail.com> wrote: > I have on a few occasions wanted a for..in..if statement and if it existed > would > have used it. However, I agree that the level of change a new statement > type > brings to the language is probably too high for this feature. > > But what if python lifted the newline requirement for blocks that contain > compound statements? That is, statements that end in a ':' can be followed > by > other statements that end in a ':' on the same line. AFAICT there would be > no > ambiguity (to the parser; to humans, depends). Doing so would add the OPs > requested feature, though it would be two statements on one line with one > extra > character. It would also essentially bring the full comprehension syntax > to for > loops since fors and ifs could be chained arbitrarily. > > # for..if > for x in y: if x in c: > some_op(x > > # nested generator-like for > for line in doc: for word in line.split(): > spellcheck(word) > > # side effect one-liner > for item in an_iterable: if condition(item): side_effect(item)) > > > Regards, > Jeremiah > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/LWPJKAN37ZV7G2GW33ID7PFMT7BNNOYO/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6COVUGA2KH7J6OOXWJYXAX7YZKDOMR57/ Code of Conduct: http://python.org/psf/codeofconduct/