Skip to content

Commit 9a12bb7

Browse files
committed
Merge branch 'master' of github.com:kennethreitz/python-guide
2 parents 6656c15 + eb1170d commit 9a12bb7

File tree

7 files changed

+58
-16
lines changed

7 files changed

+58
-16
lines changed

docs/shipping/freezing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ To create a standalone windowed OS X application, use the :code:`--windowed` opt
202202
203203
This creates a :code:`script.app` in the :code:`dist` folder. Make sure to use GUI packages in your Python code, like `PyQt <https://riverbankcomputing.com/software/pyqt/intro>`_ or `PySide <http://wiki.qt.io/About-PySide>`_, to control the graphical parts of the app.
204204

205-
There are several options in :code:`script.spec` related to Mac OS X app bundles `here <http://pythonhosted.org/PyInstaller/#spec-file-options-for-a-mac-os-x-bundle>`_. For example, to specify an icon for the app, use the :code:`icon=\path\to\icon.icns` option.
205+
There are several options in :code:`script.spec` related to Mac OS X app bundles `here <http://pythonhosted.org/PyInstaller/spec-files.html#spec-file-options-for-a-mac-os-x-bundle>`_. For example, to specify an icon for the app, use the :code:`icon=\path\to\icon.icns` option.
206206

207207

208208
Linux

docs/starting/install/osx.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ or Python 3:
7777
7878
This will take a minute or two.
7979

80+
Homebrew names the executable ``python2`` so that you can still run the system Python via the executable ``python``.
81+
82+
83+
.. code-block:: console
84+
85+
$ python -V # system Python interpreter
86+
$ python2 -V # Homebrew installed Python 2 interpreter
87+
$ python3 -V # Homebrew installed Python 3 interpreter (if installed)
88+
8089
8190
Setuptools & Pip
8291
----------------
@@ -93,6 +102,12 @@ that is recommended over ``easy_install``. It is superior to ``easy_install``
93102
in `several ways <https://python-packaging-user-guide.readthedocs.io/pip_easy_install/#pip-vs-easy-install>`_,
94103
and is actively maintained.
95104

105+
.. code-block:: console
106+
107+
$ pip2 -V # pip pointing to the Homebrew installed Python 2 interpreter
108+
$ pip3 -V # pip pointing to the Homebrew installed Python 3 interpreter (if installed)
109+
110+
96111
97112
Virtual Environments
98113
--------------------

docs/starting/install3/osx.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Pip
7070

7171
Homebrew installs ``pip3`` for you.
7272

73-
``pip3`` is the alias for the Python 3 version of ``pip`` on systems with both
74-
the Homebrew'd Python 2 and 3 installed.
73+
``pip3`` is the alias to ``pip`` pointing to the Homebrew'd Python 3.
7574

7675
Working with Python 3
7776
---------------------
@@ -84,18 +83,22 @@ version of Python 3 as well.
8483
8584
$ python
8685
87-
will launch the Python 2 interpreter.
86+
will launch the system Python interpreter.
87+
88+
.. code-block:: console
89+
90+
$ python2
91+
92+
will launch the homebrew-installed Python 2 interpreter (if any).
8893

8994
.. code-block:: console
9095
9196
$ python3
9297
93-
will launch the Python 3 interpreter.
98+
will launch the homebrew-installed Python 3 interpreter.
9499

95-
``pip3`` and ``pip`` will both be available. If the Homebrew version of Python
96-
2 is not installed, they will be the same. If the Homebrew version of Python 2
97-
is installed then ``pip`` will point to Python 2 and ``pip3`` will point to
98-
Python 3.
100+
If the Homebrew version of Python 2 is installed then ``pip2`` will point to Python 2.
101+
If the Homebrew version of Python 3 is installed then ``pip3`` will point to Python 3.
99102

100103

101104
Virtual Environments

docs/starting/install3/win.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _install3-windows:
22

33
Installing Python 3 on Windows
4-
============================
4+
==============================
55

66
First, download the `latest version <https://www.python.org/ftp/python/3.6.0/python-3.6.0.exe>`_
77
of Python 3.6 from the official website. If you want to be sure you are installing a fully

docs/writing/documentation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ more information about a function, what it does, any exceptions it may raise,
205205
what it returns, or relevant details about the parameters.
206206

207207
For more detailed documentation of code a popular style is the one used for the
208-
Numpy project, often called `Numpy style`_ docstrings. While it can take up a
209-
few more lines the previous example, it allows the developer to include a lot
208+
Numpy project, often called `Numpy style`_ docstrings. While it can take up more
209+
lines than the previous example, it allows the developer to include a lot
210210
more information about a method, function, or class. ::
211211

212212
def random_number_generator(arg1, arg2):

docs/writing/gotchas.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,27 @@ Here's nice trick for removing all of these files, if they already exist::
230230
Run that from the root directory of your project, and all ``.pyc`` files
231231
will suddenly vanish. Much better.
232232

233+
Version Control Ignores
234+
~~~~~~~~~~~~~~~~~~~~~~~
233235

236+
If you still need the ``.pyc`` files for performance reasons, you can always add them
237+
to the ignore files of your version control repositories. Popular version control
238+
systems have the ability to use wildcards defined in a file to apply special
239+
rules.
234240

241+
An ignore file will make sure the matching files don't get checked into the repository.
242+
Git_ uses ``.gitignore`` while Mercurial_ uses ``.hgignore``.
235243

244+
.. _Git: https://git-scm.com/
245+
.. _Mercurial: https://www.mercurial-scm.org/
236246

247+
At the minimum your ignore files should look like this.
237248

249+
::
238250

251+
syntax:glob # This line is not needed for .gitignore files.
252+
*.py[cod] # Will match .pyc, .pyo and .pyd files.
253+
__pycache__/ # Exclude the whole folder
239254

240-
241-
242-
255+
You may wish to include more files and directories depending on your needs.
256+
The next time you commit to the repository, these files will not be included.

docs/writing/structure.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,17 @@ folder named :file:`my` which is not the case. There is an
391391
dot notation should be used in the Python docs.
392392

393393
If you'd like you could name your module :file:`my_spam.py`, but even our
394-
friend the underscore should not be seen often in module names.
394+
friend the underscore should not be seen often in module names. However, using other
395+
characters (spaces or hyphens) in module names will prevent importing
396+
(- is the subtract operator), so try to keep module names short so there is
397+
no need to separate words. And, most of all, don't namespace with underscores, use submodules instead.
398+
399+
.. code-block:: python
400+
401+
# OK
402+
import library.plugin.foo
403+
# not OK
404+
import library.foo_plugin
395405
396406
Aside from some naming restrictions, nothing special is required for a Python
397407
file to be a module, but you need to understand the import mechanism in order

0 commit comments

Comments
 (0)