Python 2.2 code continues running before list comprehension is completed?
__peter__ at web.de
Mon Jul 19 18:31:36 CEST 2004
Heiko Wundram wrote:
> IIRC, Python 2.2 didn't support list comprehensions (feature new as of
> 2.3), so you'll have to work around that by creating some form of simple
> for loop which does what you want, esp. considering that VARIOUS
> CONDITIONS ON x seems to be a lot more than just a simple check (which
> will make the code a helluvalot cleaner if spelled out).
Python 2.2.1 (#1, Sep 10 2002, 17:49:17)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> [c for c in "you are wrong"][-5:]
['w', 'r', 'o', 'n', 'g']
(but only with regard to list comprehensions)
More information about the Python-list