apostrophe or double quote?

Steve Holden steve at holdenweb.com
Tue Feb 7 23:22:49 EST 2006


Huy wrote:
> I've been unable to find information clarifying this but.  What is the
> difference between 'somestring' and "somestring"?  When I use type() it
> still reports as string.  If there is a difference could someone point
> me to documentation or explain when to use and when not to?  Hope I
> sound clear.
> 
It's just easier to have two permitted string quotes. That way, if your 
string has an apostrophe in it you can say

     s = "it's"

and if it has a double quote in it you can say

     s = 'The double quote (") rules'

So there's really no difference at all. You can also use escaping to 
achieve the same end:

     s = "The double quote (\") rules"

if you prefer.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list