Coding Style: Quotes

Michael Stenner mstenner at phy.duke.edu
Thu Sep 12 21:33:53 EDT 2002


On Fri, Sep 13, 2002 at 01:14:21AM +0000, Bob X wrote:
> Michael Stenner wrote:
> <snip>
> > Since there is no "physical" difference between them, I can't imagine
> > why it would matter.  The only reason there "needs" to be two is for
> > nested quoting.  Sure, it would be annoying to alternate for each
> > string, but beyond that...
> Don't you have to escape a single quote within a single quote whereas 
> you do not while using a double quote?
> 
> i.e. 'It\'s raining'  "It's raining"

Yes.  But they are identical in that the reverse is also true.  For
example:

"It\"s raining"  'It"s raining'

I know it's incorrect english grammar, but that's not really relevant
here.

This is in contrast to languages where the single and double quotes
have fundamentally different roles.  For example, in c, "s" and 's'
are radically different.  In perl, "$_" and '$_' are again very
different.
					-Michael

P.S.  As a matter of style, I'm sure most of us would agree that 
  "It's raining" is preferable to 'It\'s raining', just as
  'she said "wait"' is preferable to "she said \"what\"".

-- 
  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner at phy.duke.edu
  Box 90305, Durham N.C. 27708-0305




More information about the Python-list mailing list