{"thread":{"id":"32785","subject":"[PATCH v3] CodingGuidelines: add Python coding guidelines","startedAt":"2013-01-30T20:47:32Z","lastAt":"2013-01-30T20:47:32Z","messageCount":1,"participants":["John Keeping"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"208317","messageId":"5c15718db7bd34da2679c88ddabe3e63b0117ef2.1359578487.git.john@keeping.me.uk","threadId":"32785","inReplyTo":null,"subject":"[PATCH v3] CodingGuidelines: add Python coding guidelines","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-30T20:47:32Z","receivedAt":"2013-01-30T20:47:32Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"These are kept short by simply deferring to PEP-8.  Most of the Python\ncode in Git is already very close to this style (some things in contrib/\nare not).\n\nRationale for version suggestions:\n\n - Amongst the noise in [1], there isn't any disagreement about using\n   2.6 as a base (see also [2]), although Brandon Casey recently added\n   support for 2.4 and 2.5 to git-p4 [3].\n\n - Restricting ourselves to 2.6+ makes aiming for Python 3 compatibility\n   significantly easier [4].\n\n - Advocating Python 3 support in all scripts is currently unrealistic\n   because:\n\n     - 'p4 -G' provides output in a format that is very hard to use with\n       Python 3 (and its documentation claims Python 3 is unsupported).\n\n     - Mercurial does not support Python 3.\n\n     - Bazaar does not support Python 3.\n\n - But we should try to make new scripts compatible with Python 3\n   because all new Python development is happening on version 3 and the\n   Python community will eventually stop supporting Python 2 [5].\n\n - Python 3.1 is required to support the 'surrogateescape' error handler\n   for encoding/decodng filenames to/from Unicode strings and Python 3.0\n   is not longer supported.\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/210329\n[2] http://article.gmane.org/gmane.comp.version-control.git/210429\n[3] http://thread.gmane.org/gmane.comp.version-control.git/214579\n[4] http://docs.python.org/3.3/howto/pyporting.html#try-to-support-python-2-6-and-newer-only\n[5] http://www.python.org/dev/peps/pep-0404/\n\n---\nChanges since v2:\n\n- Tone down discussion of the byte string prefix.\n\n- Change \"is supported since\" to \"has been supported since\".\n\n Documentation/CodingGuidelines | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex 69f7e9b..432c6cd 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -179,6 +179,20 @@ For C programs:\n  - Use Git's gettext wrappers to make the user interface\n    translatable. See \"Marking strings for translation\" in po/README.\n \n+For Python scripts:\n+\n+ - We follow PEP-8 (http://www.python.org/dev/peps/pep-0008/).\n+\n+ - As a minimum, we aim to be compatible with Python 2.6 and 2.7.\n+\n+ - Where required libraries do not restrict us to Python 2, we try to\n+   also be compatible with Python 3.1 and later.\n+\n+ - When you must differentiate between Unicode literals and byte string\n+   literals, it is OK to use the 'b' prefix.  Even though the Python\n+   documentation for version 2.6 does not mention this prefix, it has\n+   been supported since version 2.6.0.\n+\n Writing Documentation:\n \n  Every user-visible change should be reflected in the documentation.\n-- \n1.8.1.2.633.gbba9ccc\n"}]}