[Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax (original) (raw)
Josiah Carlson jcarlson at uci.edu
Mon May 22 21:28:37 CEST 2006
- Previous message: [Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax
- Next message: [Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Heiko Wundram <me+python-dev at modelnine.org> wrote:
Why isn't this good practice? It's not always sensible to refactor loop code to call methods (to make the loop body shorter), and it's a pretty general case that you only want to iterate over part of a generator, not over the whole content. Because of this, list comprehensions grew the 'if'-clause. So: why doesn't the for-loop?
List comprehensions grew an if clause because they are expressions that were supposed to replace one of the most the most common idioms in Python:
x = []
for i in ...:
if ...:
x.append(...)
And you know what? They've done that very well. Seemingly so well that you are asking for the list comprehension syntax to make it back into for loops. So far, you have failed to convince me (and most others it looks like) that it is a good idea, you have re-hashed the same arguments you made in the PEP, and Guido chimed in as the first message to say:
"-1. The contraction just makes it easier to miss the logic."
"This was proposed and rejected before."
- Guido
If you want some advice: let it drop.
- Josiah
- Previous message: [Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax
- Next message: [Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]