apostrophe or double quote?

Terry Hancock hancock at anansispaceworks.com
Wed Feb 8 19:00:04 EST 2006


On Wed, 8 Feb 2006 11:57:00 -0600
skip at pobox.com 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 (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com




More information about the Python-list mailing list