Comment Comment by a_bonobo One interesting side-thing with list comprehensions in Python 2 vs. Python 3:Python 2.7:>list_of_numbers = [1,2,3]>[x/2 for x in list_of_numbers]>print(x)3Python 3:>list_of_numbers = [1,2,3]>[x/2 for x in list_of_numbers]>print(x)NameError: name 'x' is not definedThey "leak" their variables in Python 2, if you're someone who reuses variables this can lead to an enormous headache! parent a_bonobo 10 years ago
Python 2.7:
>list_of_numbers = [1,2,3]
>[x/2 for x in list_of_numbers]
>print(x)
3
Python 3:
>list_of_numbers = [1,2,3]
>[x/2 for x in list_of_numbers]
>print(x)
NameError: name 'x' is not defined
They "leak" their variables in Python 2, if you're someone who reuses variables this can lead to an enormous headache!