Skip to content

Instantly share code, notes, and snippets.

@mattias-lidman
Created October 9, 2014 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattias-lidman/228a4ce81fd9f2917d46 to your computer and use it in GitHub Desktop.
Save mattias-lidman/228a4ce81fd9f2917d46 to your computer and use it in GitHub Desktop.
>>> ( x for x in [1,2,3] )
<generator object <genexpr> at 0x7f7de8dc6cd0>
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> # OK, seems legit
>>> { x:x for x in [1,2,3] }
{1: 1, 2: 2, 3: 3}
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> # So far so good...
>>> [ x for x in [1,2,3] ]
[1, 2, 3]
>>> x
3
>>> # MIND = BLOWN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment