Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:07:12+00:00 2026-05-26T15:07:12+00:00

I’m writing a Python parser to learn Flex and Bison, and I’m trying to

  • 0

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 Python

produces no error.

b.py:

    \
# This is not valid Python

produces this error:

  File "b.py", line 1
    \
    ^
IndentationError: unexpected indent

and c.py:

if True:
    pass
    \
    # This is not valid Python

produces this error:

  File "c.py", line 4
    # This is not valid Python
                             ^
SyntaxError: invalid syntax

I’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)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:07:12+00:00Added an answer on May 26, 2026 at 3:07 pm

    It’s an implementation detail.

    Here’s how a few different implementations respond to your code:

                     a.py  b.py  c.py    
                     ----  ----  ----
    CPython 2.6.5     ok    bad   bad
    CPython 3.?       ok    bad   bad
    Jython 2.2.1      ok    ok    bad
    Jython 2.5.2      bad   bad   bad
    IronPython 2.7.1  ok    bad   ok
    

    My reading of the Exlplicit Line Joining section of the Python Language Reference is that all three examples could be treated as valid:

    Two or more physical lines may be joined into logical lines using
    backslash characters (\), as follows: when a physical line ends in a
    backslash that is not part of a string literal or comment, it is
    joined with the following forming a single logical line, deleting the
    backslash and the following end-of-line character.

    If CPython were changed to accept all three examples as valid I doubt it would be noticed by its users, change the character of the language, or break any code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.