Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18023

Re: Possible bug in string handling (with kludgy work-around)

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sorts': 0.04; 'subject:bug': 0.04; '"""': 0.07; "'''": 0.09; '>to': 0.09; 'backslash': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:string': 0.09; '"python': 0.15; 'bieber': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'gmt,': 0.16; 'message- id:@4ax.com': 0.16; 'received:wlfraed': 0.16; 'string:': 0.16; 'subject:handling': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'wrote:': 0.18; "'python": 0.18; 'url:home': 0.21; 'dec': 0.22; '>the': 0.23; 'received:166': 0.23; 'lee': 0.28; 'looks': 0.29; 'print': 0.29; 'tightly': 0.30; 'header:X -Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'subject:work': 0.34; 'subject:with': 0.36; 'charset:us-ascii': 0.37; 'could': 0.37; 'using': 0.38; 'steven': 0.38; 'too,': 0.38; 'received:org': 0.38; 'some': 0.38; 'should': 0.39; 'mark': 0.39; 'subject: (': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'double': 0.61; 'dennis': 0.73; 'marker': 0.84; 'packed': 0.84; 'subject:Possible': 0.84; 'fonts,': 0.91; 'quotation': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Possible bug in string handling (with kludgy work-around)
Date Tue, 27 Dec 2011 09:53:04 -0500
References <mailman.4112.1324938867.27778.python-list@python.org> <4ef91afb$0$29973$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host mobile-166-147-101-088.mycingular.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4133.1324997611.27778.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324997611 news.xs4all.nl 6860 [2001:888:2000:d::a6]:34331
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18023

Show key headers only | View raw


On 27 Dec 2011 01:10:19 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:


>The only time you should backslash-escape a quotation mark is if you need 
>to include both sorts in a single string:
>
>print "Python has both single ' and double \" quotation marks."
>print 'Python has both single \' and double " quotation marks.'
>

	You can get by without the backslash in this situation too, by using
triple quoting:

print """Python has both single ' and double " quotation marks."""
(substitute ''' for """ if it looks better to you, as long as you use
the same marker at both ends. I find """ clearer, ''' could be a " and '
packed tightly in some fonts, "', whereas """ can only be one construct)
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Possible bug in string handling (with kludgy work-around) Charles Hixson <charleshixsn@earthlink.net> - 2011-12-26 14:23 -0800
  Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-26 14:48 -0800
    Re: Possible bug in string handling (with kludgy work-around) Chris Angelico <rosuav@gmail.com> - 2011-12-27 10:05 +1100
  Re: Possible bug in string handling (with kludgy work-around) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-27 01:10 +0000
    Re: Possible bug in string handling (with kludgy work-around) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-12-27 09:53 -0500
      Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 10:04 -0800
        Re: Possible bug in string handling (with kludgy work-around) Lie Ryan <lie.1296@gmail.com> - 2011-12-28 08:23 +1100
        Re: Possible bug in string handling (with kludgy work-around) Terry Reedy <tjreedy@udel.edu> - 2011-12-27 16:38 -0500
          Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 16:57 -0800
            Re: Possible bug in string handling (with kludgy work-around) Lie Ryan <lie.1296@gmail.com> - 2011-12-29 04:54 +1100
        Re: Possible bug in string handling (with kludgy work-around) Terry Reedy <tjreedy@udel.edu> - 2011-12-27 16:38 -0500

csiph-web