14.12.19 23:37, komissar.off.and...@gmail.com пише:
Hello!
I think it will be useful in Python syntax if we can use "elif" in "for" and "while" 
statements besides "else"

Example
for i in range(j):
     ...
elif i > 5:
     ...
else:
     ...

What you think about this change?

I sometimes with this feature (and also for "else" in a "try" statement). This would allow to save an indentation level in some cases. But:

1. "else" in a loop is confusing itself, and "elif" would confusing even more.

2. We use the same keyword "else" with different semantic in different statements. If we would use different keywords (like "otherwise" or "afterloop"), combining it with "if" would not look more natural than combining "else" and "for" into "elfor".

3. There are too small use cases for this. I need this maybe 1-3 times in a year that is nothing in comparison of other uses of "else" which cannot be combined with "if".

So I never proposed this idea. I prefer to keep the grammar simpler.
_______________________________________________
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/BEO3RGBHDM5QSYVCWSZXW4HUNS564VP6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to