Coding Style: Quotes

Amit Patel amitp at Xenon.Stanford.EDU
Fri Sep 13 17:56:21 EDT 2002


 Richie Hindle  <richie at entrian.com> wrote:
| 
| > I'm curious if others have adopted any standards for choice of single vs.
| > double quotation marks to delimit strings.
| 
| I tend to use double-quotes for user-visible strings, and single quotes
| for internal ones.  For instance:
| 
|     print "Hello, %s." % userRecord[ 'name' ]
| 
| In a library module, docstrings count as user-visible because the
| "users" include the programmer using the library:
| 
|     def greetUser( userRecord ):
|         """Says hello to the user."""
|         print "Hello, %s." % userRecord[ 'name' ]
| 
| Don't ask me why I starting using this standard, or where the idea came
| from, 'cos I have no idea.  It just seems to make sense.

I do this too.  I was influenced by Lisp / Scheme, where 'foo is a
symbol.  In Python I use 'foo' where I would have used a symbol in
Lisp and "foo" where I would have used a string in Lisp.

     - Amit




-- 
--
Amit J Patel, Computer Science Department, Stanford University
http://www-cs-students.stanford.edu/~amitp/



More information about the Python-list mailing list