Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2.7': 0.04; 'instance,': 0.05; 'string,': 0.05; 'character,': 0.07; 'python': 0.08; '>>>>': 0.09; 'chose': 0.09; 'pm,': 0.10; '>>>': 0.12; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'double-quote': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ha!': 0.16; 'posted,': 0.16; 'repr': 0.16; 'repr()': 0.16; 'said.': 0.16; 'string:': 0.16; 'subject:syntax': 0.16; 'header:In-Reply-To:1': 0.21; 'literal': 0.23; 'string': 0.26; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'sun,': 0.30; 'print': 0.31; 'to:addr:python-list': 0.33; "isn't": 0.33; 'chris': 0.34; 'subject: ?': 0.35; 'subject:What': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'simply': 0.60; 'double': 0.62; 'making': 0.67; 'enclosed': 0.68; 'subject:this': 0.76; '"foo"': 0.84; '11:41': 0.84; 'candide': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=j+s8LWpOQQ/0mT28R8mYIzKXpedw4LfP63qrbpO+tR4=; b=Ysc40hb0fThSiUwBGdZZcKIqpJXjjcOzEU+ASrjpDPQXFnI1Bv0WudGS2/Hm0GrUtj qIbc23p3EWhtKaMXsLJi4t9nKqWTXiB99wGc4gzx4tm8JRiKSWoP81DqqRkCw8BEr12W Bq4aEsrIgIFtoF9pu5c4CgDELsaHZ9UIMeejg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ub/E3tqrBashQ301F/J0hydH66mP1kSFQlQ8W189kWzdNgwuJVwTjSVNks+DGTlBJi GpZuZz8YsTmixy1vAVRs/IfFfZ3lQFpZENraSrqbWv0mu0zw1CP/v7I/pryYFlTikrzJ QrCUk616JxhR9C3O7+UCHzHLzF1bSuS06gqQc= MIME-Version: 1.0 In-Reply-To: <4dfdfc99$0$715$426a34cc@news.free.fr> References: <4dfdfc99$0$715$426a34cc@news.free.fr> Date: Mon, 20 Jun 2011 00:03:31 +1000 Subject: Re: What is this syntax ? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308492215 news.xs4all.nl 49041 [::ffff:82.94.164.166]:59065 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7959 On Sun, Jun 19, 2011 at 11:41 PM, candide wrote: > With Python 2.7 : > >>>> x="foo" >>>> print '"'+x+'"' > "foo" >>>> As Laurent posted, it's simply a literal double-quote character, enclosed in single quotes. But for making a quoted string, this isn't reliable (what if there's a double quote in the string itself?), so you may want to try repr() which makes a theoretically evalable string: >>> x="foo" >>> print repr(x) 'foo' >>> x=raw_input() "Ha ha! 'Tis mine!", he said. >>> print repr(x) '"Ha ha! \'Tis mine!", he said.' In this instance, repr chose to use single quotes, but the same applies. Chris Angelico