I'm writing a Python parser to learn Flex and Bison, and I'm trying to find out why only the first of these programs is valid Python.
a.py:
\# This is valid Pythonproduces no error.
b.py:
\# This is not valid Pythonproduces this error:
File "b.py", line 1 \ ^IndentationError: unexpected indentand c.py:
if True: pass \ # This is not valid Pythonproduces this error:
File "c.py", line 4 # This is not valid Python ^SyntaxError: invalid syntaxI'm using Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 (Ubuntu 10.04); However, testing on ideone.com suggests the behavior is the same on Python 3.
See also: How can I do a line break (line continuation) in Python (split up a long line of source code)?