I think the more realistic option is to allow "if" in the for statement.
This has been suggested before, you can find it in the archives.

On Mon, 28 Jun 2021, 22:50 Max Shouman, <[email protected]> wrote:

> This is more of a syntactic sugar than an actual new feature, but...
> Exactly, 'but' is the idea: a special keyword to be used in for statements
> to exclude values ​​from the iterable.
>
> E.g., when iterating over a generator:
> >>> for i in range(0, 10) but (2, 8):
> would implicitly create a new generator comprehensively, as in:
> >>> for i in (j for j in range(0, 10) if j not in [2, 8]):
>
> It might not add such a feature to justify the definition of a but_stmt in
> python.gram, but it's fully compliant with Python's philosophy of concise,
> clear and elegant code.
>
> #road to a programming natural language (jk)
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/YI2ILMNQDFKLDLJN4SLRNWEQA3CPGX5U/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/HXM445TJARK2WAF6XVTOPXYV2T2LTD2A/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to