Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7973
| From | Roy Smith <roy@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: What is this syntax ? |
| Date | 2011-06-19 11:39 -0400 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <roy-2A6DC8.11394419062011@news.panix.com> (permalink) |
| References | <4dfdfc99$0$715$426a34cc@news.free.fr> <4dfe10d1$0$28053$426a34cc@news.free.fr> |
In article <4dfe10d1$0$28053$426a34cc@news.free.fr>, candide <candide@free.invalid> wrote: > OK, thanks for your explanation, it was just stringisation ! > > > I erroneously focused on > > +x+ > > as a kind of placeholder unknown to me, instead of left and right > concatenations ;) > > It would be more readable for me if it were edited > > >>> print '"' + x + '"' # better spacing > "foo" > >>> > > or with string formatting : > > >>> x="foo" > >>> print '"%s"' %x > "foo" > >>> This is one of the (very) few places PHP wins over Python. In PHP, I would write this as print "'$x'" which seems easier to read than any of the Python versions. Of course, sharp-eyed readers will notice that I inverted the single and double quotes because print '"$x"' doesn't work. If you really wanted to replicate the output exactly, you would have to do print "\"$x\"" by which time you'd probably run back to writing it in Python :-)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is this syntax ? candide <candide@free.invalid> - 2011-06-19 15:41 +0200
Re: What is this syntax ? Laurent Claessens <moky.math@gmail.com> - 2011-06-19 15:50 +0200
Re: What is this syntax ? Noah Hall <enalicho@gmail.com> - 2011-06-19 14:58 +0100
Re: What is this syntax ? Chris Angelico <rosuav@gmail.com> - 2011-06-20 00:03 +1000
Re: What is this syntax ? candide <candide@free.invalid> - 2011-06-19 17:08 +0200
Re: What is this syntax ? Roy Smith <roy@panix.com> - 2011-06-19 11:39 -0400
Re: What is this syntax ? rusi <rustompmody@gmail.com> - 2011-06-19 09:58 -0700
Re: What is this syntax ? Roy Smith <roy@panix.com> - 2011-06-19 16:20 -0400
Re: What is this syntax ? Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-06-19 23:06 +0200
Re: What is this syntax ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-19 23:19 +0000
Re: What is this syntax ? Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-06-20 07:42 +0200
Re: What is this syntax ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-19 15:29 -0700
csiph-web