You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 executed because Python is not able to compile it in the first place. Try adding a print call before the try-except block and you'll see it never gets executed either :)
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.
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).
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: