Re: apostrophe or double quote?
On 09 Feb 2006 12:54:04 + (GMT) Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > Terry Hancock <[EMAIL PROTECTED]> wrote: > >[EMAIL PROTECTED] wrote: > >> Just to present a complete picture, not mentioned in > >this > thread are triple-quoted strings: > >> [ ... ] > >Also in the mode of beating a dead horse ... ;-) > > > >Some people prefer to use single quotes for 'labels' > >(i.e. a name which is meaningful to the program, but not > >to the user), and reserve either double-quotes or > >triple-double-quotes for text to be shown to the user. > > [ ... ] > > Hmm, I made both these points a couple of posts upthread, > but it didn't appear to get through the news->mail > gateway. Ah well, it all came up on the list about a month or two ago anyway (I guess. I don't know, maybe it was a year ago), so I'm just repeating it. -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
Terry Hancock <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: >> Just to present a complete picture, not mentioned in this >> thread are triple-quoted strings: >> [ ... ] >Also in the mode of beating a dead horse ... ;-) > >Some people prefer to use single quotes for 'labels' (i.e. a >name which is meaningful to the program, but not to the >user), and reserve either double-quotes or >triple-double-quotes for text to be shown to the user. > [ ... ] Hmm, I made both these points a couple of posts upthread, but it didn't appear to get through the news->mail gateway. -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
On Wed, 8 Feb 2006 11:57:00 -0600 [EMAIL PROTECTED] wrote: > Just to present a complete picture, not mentioned in this > thread are triple-quoted strings: > > 'abc' == '''abc''' == "abc" == """abc""" > > Triple-quoted strings are no different than regular > strings, though they do allow literal newlines to be > embedded in the string. Their presence is most often > detected in doc strings precisely for this reason. Also in the mode of beating a dead horse ... ;-) Some people prefer to use single quotes for 'labels' (i.e. a name which is meaningful to the program, but not to the user), and reserve either double-quotes or triple-double-quotes for text to be shown to the user. This tends to make things slightly easier when you have to go back and use gettext to internationalize your code. But that's a matter of taste. It is interesting to note, however, that the Python repr() function prefers to use single quotes, using double quotes only when a single quote is embedded in the string. Cheers, Terry -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
Just to present a complete picture, not mentioned in this thread are triple-quoted strings: 'abc' == '''abc''' == "abc" == """abc""" Triple-quoted strings are no different than regular strings, though they do allow literal newlines to be embedded in the string. Their presence is most often detected in doc strings precisely for this reason. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
Thank you for all your help; it makes perfect sense now. -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
Steve Holden <[EMAIL PROTECTED]> wrote: >Huy wrote: >> I've been unable to find information clarifying this but. What is the >> difference between 'somestring' and "somestring"? >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. Or triple quoting: s = """The double quote (") rules""" I've seen someone around here use 'somestring' for internal values (dict keys and the like) and "somestring" for values being shown to the user, so it's easy(ish) to tell what may need translating or can otherwise safely be changed. I like this convention (provided it remains a convention). -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
Steve Holden wrote: > 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" It's particularly handy if you are building strings of a language that already has its own quotes, e.g. SQL or XML: sql_snippet = " where name='Max'" html_snippet = ' align="left"' -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: apostrophe or double quote?
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. > There is no difference. However, compare the following: py> 'internal quotes: "' 'internal quotes: "' py> "internal apostrophe: '" "internal apostrophe: '" py> 'astring' 'astring' py> "astring" 'astring' -- http://mail.python.org/mailman/listinfo/python-list
apostrophe or double quote?
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. -- http://mail.python.org/mailman/listinfo/python-list