Skip to content

Instantly share code, notes, and snippets.

@maphew
Last active January 15, 2016 23:11
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 maphew/67c88807bf97bf67fbf9 to your computer and use it in GitHub Desktop.
Save maphew/67c88807bf97bf67fbf9 to your computer and use it in GitHub Desktop.
Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> my_list = 'one two tee'.split()
>>>
>>> my_list
['one', 'two', 'tee']
>>>
>>> [print x for x in my_list]
File "<stdin>", line 1
[print x for x in my_list]
^
SyntaxError: invalid syntax
>>>
>>> [print(x) for x in my_list]
File "<stdin>", line 1
[print(x) for x in my_list]
^
SyntaxError: invalid syntax
>>>
>>> from __future__ import print_function
>>>
>>> [print(x) for x in my_list]
one
two
tee
[None, None, None]
>>>
@maphew
Copy link
Author

maphew commented Jan 15, 2016

updated to include complete console output (previously was just the curious bits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment