Changes between Version 11 and Version 12 of PythonGuidelines


Ignore:
Timestamp:
Apr 3, 2010, 1:19:59 PM (15 years ago)
Author:
Chris Jerdonek
Comment:

Added a style section.

Legend:

Unmodified
Added
Removed
Modified
  • PythonGuidelines

    v11 v12  
    2828  * webkitpy/python24/: code that needs to work under Python 2.4 (currently just the version-checking code)
    2929  * [http://trac.webkit.org/browser/trunk/WebKitTools/Scripts/webkitpy webkitpy/thirdparty/]: all third-party code in webkitpy
     30
     31== Style ==
     32
     33For discussion purposes, here are some style guidelines to consider in addition to [http://www.python.org/dev/peps/pep-0008/ PEP8]:
     34
     35 * 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.
     36 * Order `from` and `import` statements by the name of the leading module instead of putting all `from` statements before `import` statements:
     37{{{
     38# Correct:
     39import logging
     40from optparse import OptionParser
     41import sys
     42
     43# Incorrect:
     44from optparse import OptionParser
     45import logging
     46import sys
     47}}}
     48 This keeps the ordering the same when chaning a `from` statement to an `import` statement, or vice versa.
    3049
    3150== Upgrading from Python 2.3 or Python 2.4 ==