Tricky Areas in Python
Fredrik Lundh
fredrik at pythonware.com
Tue Oct 25 04:37:28 EDT 2005
Alex Martelli wrote:
> No, LC goes back a long way -- I think it was in 2.0 already, 2.1 for
> sure.
$ python1.5 -c "print [x for x in 'abc']"
File "<string>", line 1
print [x for x in 'abc']
^
SyntaxError: invalid syntax
$ python2.0 -c "print [x for x in 'abc']"
['a', 'b', 'c']
I was a bit surprised to find that 2.0 had variables, though:
$ python2.0 -c "[x for x in y]"
Traceback (most recent call last):
File "<string>", line 1, in ?
NameError: There is no variable named 'y'
$ python2.1 -c "[x for x in y]"
Traceback (most recent call last):
File "<string>", line 1, in ?
NameError: name 'y' is not defined
;-)
</F>
More information about the Python-list
mailing list