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 8953639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:08:37+00:00 2026-06-15T14:08:37+00:00

My Python version is: ~$ python –version Python 2.6.6 I tried following in Python

  • 0

My Python version is:

~$ python --version  
Python 2.6.6

I tried following in Python (I wants to show all):

1: \ use as escape sequence

>>> str('Let\'s Python')       
"Let's Python"

2: \ use as escape sequence

>>> 'Let\'s Python'             
"Let's Python"

3: str() and print as value not type

>>> print 'Let\'s Python'       
Let's Python

4: its Python a raw string

>>> repr('Let\'s Python')      
'"Let\'s Python"'

[QUESTION]

5: Python raw string

>>> print r'Let\'s Python'    
Let\'s Python

6: This, I do not understand followings:

>>> r'Let\'s Python'            
"Let\\'s Python"

>>> r'\\'
'\\\\'

Why \\ ? Why output in 5 and 6 are different?
r and repr() are same not same?
Also please explain about internal representation of string and raw strings are same or different.

  • 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-06-15T14:08:38+00:00Added an answer on June 15, 2026 at 2:08 pm

    You are confusing raw string literals r'' with string representations. There is a big difference. repr() and r'' are not the same thing.

    r'' raw string literals produce a string just like a normal string literal does, with the exception to how it handles escape codes. The produced result is still a python string. You can produce the same strings using either a raw string literal or a normal string literal:

    >>> r'String with \n escape ignored'
    'String with \\n escape ignored'
    >>> 'String with \\n escape ignored'
    'String with \\n escape ignored'
    

    When not using a r'' raw string literal I had to double the slash to escape it, otherwise it would be interpreted as the newline character. I didn’t have to escape it when using the r'' syntax because it does not interpret escape codes such as \n at all. The output, the resulting python string value, is exactly the same:

    >>> r'String with \n escape ignored' == 'String with \\n escape ignored'
    True
    

    The interpreter is using repr() to echo those values back to us; the representation of the python value is produced:

    >>> print 'String'
    String
    >>> print repr('String')
    'String'
    >>> 'String'
    'String'
    >>> repr('String')
    "'String'"
    

    Notice how the repr() result includes the quotes. When we echo just the repr() of a string, the result is itself a string, so it has two sets of quotes. The other " quotes mark the start and end of the result of repr(), and contained within that is the string representation of the python string String.

    So r'' is a syntax to produce python strings, repr() is a method to produce strings that represent a python value. repr() also works on other python values:

    >>> print repr(1)
    1
    >>> repr(1)
    '1'
    

    The 1 integer is represented as a string '1' (the character 1 in a string).

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

Sidebar

Related Questions

In older version of python, 'str' object has no attribute 'format error will be
i have installed lxml2.2.2 on windows platform(i m using python version 2.6.5).i tried this
TextMate seems to use the built-in Python version I assume (sys.path doesn't work). How
python version 2.4 # pip install psycopg2 Getting the following error: Downloading/unpacking psycopg2 Running
I use python version of libtorrent . When I run a torrent session for
Via fink install I put the following Python version on my Mac OS X
I am using Python Version 3.2. Have the following code: for row2 in reader2:
Is there a Python version of the following if - else statement in C++
I have a python script which runs and generates a version-file. I use the
I have the following shell script to query the python version. It gives me

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.