First page Back Continue Last page Overview Image

„A dirty little secret“

Python2:

>>> x = "This value will be changed in the list comprehension"

>>> res = [x for x in range(3)]

>>> res

[0, 1, 2]

>>> x

2

Python3:

>>> x = "Python 3 fixed the dirty little secret"

>>> res = [x for x in range(3)]

>>> print(res)

[0, 1, 2]

>>> x

'Python 3 fixed the dirty little secret'

>>>