homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: feature request: a conditional "for" statement
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.4, Python 3.1, Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: zero79
Priority: normal Keywords:

Created on 2009年04月23日 22:10 by zero79, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg86377 - (view) Author: Michael Gilbert (zero79) Date: 2009年04月23日 22:10
hello, i've recently been working on some code where i am processing a 
list, but excluding certain items. the solution is to use a list 
comprehension in the for statement, which for example looks like:
 for m in [n for n in range( 0 , 5 ) if n != 2]
determining what's going on here isn't immediately obvious (i.e. what's 
this new variable n doing?). it would be nice to have a more 
streamlined syntax such as:
 for m in range( 0 , 5 ) with m != 2
which is much cleaner and obvious. the statements following "with" 
could be any conditional expression.
this is just a wishlist item, and i understand that it wouldn't have 
much priority in the grand scheme of things. thank you for your 
consideration.
msg86378 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009年04月23日 22:19
You should bring this up on the python-ideas mailing list. I'm closing
this unless it gets support on that list or python-dev.
msg86379 - (view) Author: Michael Gilbert (zero79) Date: 2009年04月23日 22:20
hello, i've recently been working on some code where i am processing a 
list, but excluding certain items. the solution is to use a list 
comprehension in the for statement, which for example looks like:
 for m in [n for n in range( 0 , 5 ) if n != 2]
determining what's going on here isn't immediately obvious (i.e. what's 
this new variable n doing?). it would be nice to have a more 
streamlined syntax such as:
 for m in range( 0 , 5 ) with m != 2
which is much cleaner and obvious. the statements following "with" 
could be any conditional expression.
this is just a wishlist item, and i understand that it wouldn't have 
much priority in the grand scheme of things. thank you for your 
consideration.
History
Date User Action Args
2022年04月11日 14:56:48adminsetgithub: 50073
2009年04月23日 22:20:24zero79setnosy: - benjamin.peterson
messages: + msg86379
2009年04月23日 22:19:30benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg86378

resolution: rejected
2009年04月23日 22:10:03zero79create

AltStyle によって変換されたページ (->オリジナル) /