[Python-Dev] On quote styles (original) (raw)
Isaac Morland ijmorlan at cs.uwaterloo.ca
Mon May 12 15:03:05 CEST 2008
- Previous message: [Python-Dev] On quote styles
- Next message: [Python-Dev] Copying cgi.parse_qs() to the urllib.parse module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] On quote styles
- Next message: [Python-Dev] Copying cgi.parse_qs() to the urllib.parse module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]