Q: quoting string without escapes

Discussion in 'Python' started by Xah Lee, Jan 31, 2005.

  1. Xah Lee

    Xah Lee Guest

    Xah Lee, Jan 31, 2005
    #1
    1. Advertising

  2. Xah Lee

    Steve Holden Guest

    Xah Lee wrote:

    > in Python, is there a way to quote a string as to avoid escaping ' or "
    > inside the string?
    >
    > i.e. like Perl's q or qq.
    > thanks.
    >
    > Xah
    >
    > http://xahlee.org/PageTwo_dir/more.html
    >

    Aren't you the guy who's telling the whole world how to write Python and
    Perl? Unusual to find arrogance and humility in such close proximity.

    Please stop cross-posting your ill-informed and inflammatory stuff to
    c.l.py and c.l.perl.m. And now I have your attention, the answer to your
    question is ...

    Use triple-quoting.

    followups-set'ly y'rs - steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
    Steve Holden, Jan 31, 2005
    #2
    1. Advertising

  3. On Mon, 31 Jan 2005 14:09:10 -0500, Steve Holden <> wrote:
    > Use triple-quoting.


    An example, for the sake of examples:

    Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> string = """ " ' " ' " ' " ' \""" """
    >>> string

    ' " \' " \' " \' " \' """ '
    >>> string = """

    .... "
    .... "
    .... "
    .... '
    .... '
    .... '
    .... \"""
    .... "\""
    .... ""\"
    .... """
    >>> string

    '\n"\n"\n"\n\'\n\'\n\'\n"""\n"""\n"""\n'

    --
    Daniel Bickett
    dbickett at gmail.com
    http://heureusement.org/
    Daniel Bickett, Jan 31, 2005
    #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. Rick Brandt

    Escapes Sequences Not Working?

    Rick Brandt, Aug 25, 2004, in forum: XML
    Replies:
    13
    Views:
    728
    Donald Roby
    Aug 28, 2004
  2. Alexander Schmolck

    re.sub replacement text \-escapes woe

    Alexander Schmolck, Feb 13, 2004, in forum: Python
    Replies:
    4
    Views:
    361
    Alexander Schmolck
    Feb 14, 2004
  3. Hans-Peter Jansen

    convert ascii escapes into binary form

    Hans-Peter Jansen, Jul 20, 2005, in forum: Python
    Replies:
    3
    Views:
    609
    Hans-Peter Jansen
    Jul 20, 2005
  4. John Nagle
    Replies:
    2
    Views:
    88
    Bart Van der Donck
    May 5, 2007
  5. Knute Johnson

    Unicode escapes and String literals?

    Knute Johnson, Dec 13, 2012, in forum: Java
    Replies:
    24
    Views:
    627
    Roedy Green
    Dec 17, 2012
Loading...

Share This Page