escaping quotes

Discussion in 'Python' started by John Salerno, Feb 28, 2006.

  1. John Salerno

    John Salerno Guest

    I'm reading through the tutorial and found this in section 3:

    >>> '"Isn\'t," she said.'

    '"Isn\'t," she said.'


    Why doesn't the escape sequence work in this case?
     
    John Salerno, Feb 28, 2006
    #1
    1. Advertising

  2. John Salerno wrote:

    > I'm reading through the tutorial and found this in section 3:
    >
    > >>> '"Isn\'t," she said.'

    > '"Isn\'t," she said.'
    >
    > Why doesn't the escape sequence work in this case?


    because the interactive prompt echos the result back to you as
    a Python literal, where possible. compare

    >>> '"Isn\'t," she said.'

    '"Isn\'t," she said.'

    with

    >>> print '"Isn\'t," she said.'

    "Isn't," she said.

    (this is explained a little later in the chapter you're reading)

    </F>
     
    Fredrik Lundh, Feb 28, 2006
    #2
    1. Advertising

  3. John Salerno

    John Salerno Guest

    Fredrik Lundh wrote:

    > because the interactive prompt echos the result back to you as
    > a Python literal, where possible. compare


    Ah, of course! I forgot it wasn't 'print'ing it.

    Thanks!
     
    John Salerno, Feb 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,532
    Andrew Thompson
    Dec 24, 2003
  2. DartmanX
    Replies:
    1
    Views:
    3,471
    Chris Smith
    Jan 23, 2005
  3. cesco

    escaping only double quotes

    cesco, Aug 31, 2007, in forum: Python
    Replies:
    2
    Views:
    278
    iapain
    Aug 31, 2007
  4. jc
    Replies:
    2
    Views:
    823
    George Ter-Saakov
    Mar 19, 2008
  5. Replies:
    7
    Views:
    190
    Thomas 'PointedEars' Lahn
    May 17, 2005
Loading...

Share This Page