Changes between Version 17 and Version 18 of PythonGuidelines


Ignore:
Timestamp:
Apr 20, 2010, 6:14:25 AM (15 years ago)
Author:
Chris Jerdonek
Comment:

Added single quote/double quote example.

Legend:

Unmodified
Added
Removed
Modified
  • PythonGuidelines

    v17 v18  
    3636For discussion purposes, here are some additional guidelines to consider:
    3737
    38  * Prefer single quotes to double quotes.  Use double quotes only if the string contains single quotes (or if you are using "triple double quotes").  This makes cutting and pasting from the console easier since Python itself behaves this way when rendering string values to the console.
     38 * Prefer single quotes to double quotes.  Use double quotes only if the string contains single quotes (or if you are using "triple double quotes").  This simplifies writing unit tests because Python behaves this way when rendering string objects to the console.  For example--
     39{{{
     40>>> list = ["blah", 'blah', '\'blah\'']
     41>>> print list
     42['blah', 'blah', "'blah'"]
     43}}}
     44 This allows console output to be cut and pasted directly into the code when writing and updating unit tests.
    3945 * Order `from` and `import` statements within a group by the name of the leading module instead of putting all `from` statements before `import` statements:
    4046{{{