On Sun, 11 May 2008, Greg Ewing wrote:

While Python doesn't have a char type (yet), I still find the distinction
between 'c' and "abc" useful to show intent (especially given my C
background

The way I tend to use them is that "xxx" is for data
operated on by the program and seen by the user,
and 'xxx' is for things that are only used internally,
e.g. enumerated type values and attribute names for use
by getattr().

I find myself doing something similar. I use '' for anything that is a dictionary key and "" for things that are strings not meant to be used for indexing, in particular the things that are looked up. Except when I don't.

When I am generating HTML using the ll.xist library, which uses constructs like this:

html.a (u'link text', href="http://url.goes.here/";)

I have just started using '' for text element contents and "" for attribute values. This way the attribute values (keyword parameters) look almost the exact same as in actual HTML (only difference is the commas) (and the escaping), and my editor seems to be designed for C-style languages where '' are for character constants and "" are for strings so it highlights them differently.

My personal opinion is that one should not use the different quoting styles at random, but I am inclined to believe that there is no single guideline that can apply to everybody.

Isaac Morland                   CSCF Web Guru
DC 2554C, x36650                WWW Software Specialist
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to