docs/code-style.rst: Update and clarify shebang rules.

This commit is contained in:
Tim Abbott
2016-05-29 05:07:50 -07:00
parent 94e4b39112
commit 1b59b6826a

View File

@@ -352,11 +352,13 @@ styles (separate lines for each selector)::
Python
------
- Scripts should start with ``#!/usr/bin/env python2.7`` and not
``#!/usr/bin/env python2.7``. See commit ``437d4aee`` for an explanation of
why. Don't put such a line on a Python file unless it's meaningful to
run it as a script. (Some libraries can also be run as scripts, e.g.
to run a test suite.)
- Scripts should start with ``#!/usr/bin/env python`` and not
``#/usr/bin/python`` (the right Python may not be installed at
/usr/bin) or ``#/usr/bin/env/python2.7`` (bad for Python 3
compatibility). Don't put a shebang line on a Python file unless
it's meaningful to run it as a script. (Some libraries can also be
run as scripts, e.g. to run a test suite.)
- The first import in a file should be
``from __future__ import absolute_import``, per `PEP
328 <http://docs.python.org/2/whatsnew/2.5.html#pep-328-absolute-and-relative-imports>`__