[Python-Dev] PEP-xxx: Unification of for statement and list-comp syntax
Heiko Wundram
me+python-dev at modelnine.org
Sun May 21 17:57:46 CEST 2006
Am Sonntag 21 Mai 2006 17:38 schrieb Guido van Rossum:
> -1. The contraction just makes it easier to miss the logic.
I actually don't think so, because it's pretty synonymous to what 'if' means
for list comprehensions which use the same keywords (that's why I called
it "unification of ... syntax"), but I guess it's superfluous to discuss this
if you're -1.
> Also, it would be a parsing conflict for the new conditional
> expressions (x if T else y).
It isn't, if you change the grammar to use testlist_safe as
the 'in'-expression, just as is used for list comprehensions. As I've said in
the PEP, I've created a patch that implements this, and Python's test suite
passes cleanly (except for a little buglet in test_dis, which stems from the
fact that the generated byte-code for a for-loop is slightly altered by this
patch).
> This was proposed and rejected before.
I haven't seen this proposed before (at least not in PEP form, or with a
working implementation against the current trunk, or just in some form of
mail on python-dev), so that's why I posted this. But, if I've really
repeated things that were proposed before, feel free to ignore this.
--- Heiko.
More information about the Python-Dev
mailing list