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: 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 Subject: Re: Possible bug in string handling (with kludgy work-around) Date: Tue, 27 Dec 2011 09:53:04 -0500 References: <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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On 27 Dec 2011 01:10:19 GMT, Steven D'Aprano 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/