Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Q: quoting string without escapes

Reply
Thread Tools

Q: quoting string without escapes

 
 
Xah Lee
Guest
Posts: n/a
 
      01-31-2005
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://www.velocityreviews.com/forums/(E-Mail Removed)
http://xahlee.org/PageTwo_dir/more.html

 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      01-31-2005
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
> (E-Mail Removed)
> 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
 
Reply With Quote
 
 
 
 
Daniel Bickett
Guest
Posts: n/a
 
      01-31-2005
On Mon, 31 Jan 2005 14:09:10 -0500, Steve Holden <(E-Mail Removed)> 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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode escapes and String literals? Knute Johnson Java 24 12-17-2012 10:42 AM
What's the proper way to remove entity escapes from a string? John Nagle Javascript 2 05-05-2007 05:46 PM
convert ascii escapes into binary form Hans-Peter Jansen Python 3 07-20-2005 08:24 PM
Escapes Sequences Not Working? Rick Brandt XML 13 08-27-2004 11:59 PM
re.sub replacement text \-escapes woe Alexander Schmolck Python 4 02-14-2004 02:30 AM



Advertisments