
I really am shocked by how many people seem to have broken ENTER keys on their keyboards. You mock. (As far as I remember you have always opposed new language features/changes. Correct me if I am wrong.) But the proposal would give people the choice of Saving a level of indentation at the cost of having two suite-introductions on the same line. Keeping the two suit-introductions on separate lines (as now) at
On 02/03/2022 20:03, David Mertz, Ph.D. wrote: the cost of an extra level of indentation. Sometimes one will be better, sometimes the other. Usually the choice will be a subjective one. That's no reason not to have the choice. Of course, this has to be weighed against the cost of the proposed change. I'm +0.5 for it. Best wishes Rob Cliffe
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 <ucodery@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-leave@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/LWPJKA... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list --python-ideas@python.org To unsubscribe send an email topython-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived athttps://mail.python.org/archives/list/python-ideas@python.org/message/6COVUG... Code of Conduct:http://python.org/psf/codeofconduct/