Zachary Ware added the comment:
Also, if you only need to support Python 2.6+, you can use 'from __future__
import print_function' and get all the benefits of 'print' as a function in
Python 2 (except the 'flush' argument, which was added in Python 3.3).
--
nosy: +zach.ware
__
R. David Murray added the comment:
By the way, if your goal is to write python2/3 compatible code, notice that
'print("hello")' is valid in python2 and will do the same thing as print
"hello"...as long as you don't use commas in the argument list to print.
--
nosy: +r.david.murray
___
Emanuel Barry added the comment:
The reason you are experiencing this behviour is because of the way Python
works. Python needs to compile your code before it can execute it. It parses
the code, sees an invalid token ('print "Hi"'), fails to compile and throws an
error. Your code never gets ex
New submission from Calvin Simpkinson:
When you execute the code:
try:
print "Hi"
except:
print("Hello")
in python 3.5, it creates a syntax error in Terminal on Mac and a pop-up error
in IDLE, while it should just print Hello in the console.
--
messages: 256083
nosy: Calvin Sim