Skip to content

Commit fa0f250

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7dfb312 + e42e21f commit fa0f250

40 files changed

+1216
-600
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ docs/_build
77

88
# Ignore .hgignore for contributors using Mercurial.
99
.hgignore
10+
11+
# Ignore files generated during build
12+
build/

Readme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Topics include:
2626
- Server configurations & tools for various web frameworks
2727
- Documentation: writing it
2828
- Testing: Jenkins & tox guides
29-
- How to easily interface ``hg`` from ``git`` easily
29+
- How to easily interface ``hg`` from ``git``
3030

3131
If you aren't fond of reading reStructuredText, there is an
3232
almost up-to-date `HTML version at docs.python-guide.org

docs/_templates/sidebarintro.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h3>Donate</h3>
1515
<p>
1616
<iframe style="border: 0; margin: 0; padding: 0;"
1717
src="https://www.gittip.com/kennethreitz/widget.html"
18-
width="48pt" height="20pt"></iframe>
18+
width="60pt" height="20pt"></iframe>
1919
</p>
2020

2121
<h3>Contributors</h3>

docs/_templates/sidebarlogo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ <h3>Donate</h3>
1515
<p>
1616
<iframe style="border: 0; margin: 0; padding: 0;"
1717
src="https://www.gittip.com/kennethreitz/widget.html"
18-
width="48pt" height="20pt"></iframe>
18+
width="60pt" height="20pt"></iframe>
1919
</p>

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@
256256
#epub_post_files = []
257257

258258
# A list of files that should not be packed into the epub file.
259-
#epub_exclude_files = []
259+
epub_exclude_files = [
260+
('search.html', 'Search'),
261+
]
260262

261263
# The depth of the table of contents in toc.ncx.
262264
#epub_tocdepth = 3

docs/contents.rst.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This part of the guide focuses on best practices for writing Python code.
3232
writing/reading
3333
writing/documentation
3434
writing/tests
35+
writing/logging
3536
writing/gotchas
3637
writing/license
3738

@@ -59,6 +60,8 @@ different scenarios.
5960
scenarios/scientific
6061
scenarios/imaging
6162
scenarios/xml
63+
scenarios/json
64+
scenarios/crypto
6265

6366

6467
Shipping Great Code

docs/dev/env.rst

Lines changed: 62 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ Your Development Environment
55
Text Editors
66
::::::::::::
77

8-
Just about anything which can edit plain text will work for writing Python code,
8+
Just about anything that can edit plain text will work for writing Python code,
99
however, using a more powerful editor may make your life a bit easier.
1010

1111

12-
VIM
12+
Vim
1313
---
1414

1515
Vim is a text editor which uses keyboard shortcuts for editing instead of menus
16-
or icons. There exist a couple of plugins and settings for the VIM editor to
16+
or icons. There are a couple of plugins and settings for the Vim editor to
1717
aid Python development. If you only develop in Python, a good start is to set
1818
the default settings for indentation and line-wrapping to values compliant with
1919
:pep:`8`. In your home directory, open a file called :file:`.vimrc` and add the
2020
following lines::
2121

2222
set textwidth=79 " lines longer than 79 columns will be broken
2323
set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns
24-
set tabstop=4 " an hard TAB displays as 4 columns
24+
set tabstop=4 " a hard TAB displays as 4 columns
2525
set expandtab " insert spaces when hitting TABs
2626
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE
2727
set shiftround " round indent to multiple of 'shiftwidth'
2828
set autoindent " align the new line indent with the previous line
2929

3030
With these settings, newlines are inserted after 79 characters and indentation
31-
is set to 4 spaces per tab. If you also use VIM for other languages, there is a
32-
handy plugin at indent_, which handles indentation settings for Python source
31+
is set to 4 spaces per tab. If you also use Vim for other languages, there is a
32+
handy plugin called indent_, which handles indentation settings for Python source
3333
files.
3434

35-
There is also a handy syntax plugin at syntax_ featuring some improvements over
36-
the syntax file included in VIM 6.1.
35+
There is also a handy syntax plugin called syntax_ featuring some improvements over
36+
the syntax file included in Vim 6.1.
3737

3838
These plugins supply you with a basic environment for developing in Python.
3939
To get the most out of Vim, you should continually check your code for syntax
4040
errors and PEP8 compliance. Luckily PEP8_ and Pyflakes_ will do this for you.
41-
If your VIM is compiled with :option:`+python` you can also utilize some very handy
41+
If your Vim is compiled with :option:`+python` you can also utilize some very handy
4242
plugins to do these checks from within the editor.
4343

4444
For PEP8 checking, install the vim-pep8_ plugin, and for pyflakes you can
@@ -51,7 +51,7 @@ order to do this, add the following lines to your :file:`.vimrc`::
5151
autocmd BufWritePost *.py call Pyflakes()
5252
autocmd BufWritePost *.py call Pep8()
5353

54-
If you are already using syntastic_ you can enable it to run Pyflakes on write
54+
If you are already using syntastic_, you can set it to run Pyflakes on write
5555
and show errors and warnings in the quickfix window. An example configuration
5656
to do that which also shows status and warning messages in the statusbar would be::
5757

@@ -61,21 +61,28 @@ to do that which also shows status and warning messages in the statusbar would b
6161
let g:syntastic_auto_loc_list=1
6262
let g:syntastic_loc_list_height=5
6363

64+
6465
Python-mode
6566
^^^^^^^^^^^
6667

67-
Python-mode_ is a complex solution in VIM for working with Python code.
68+
Python-mode_ is a complex solution for working with Python code in Vim.
6869
It has:
6970

7071
- Asynchronous Python code checking (``pylint``, ``pyflakes``, ``pep8``, ``mccabe``) in any combination
7172
- Code refactoring and autocompletion with Rope
7273
- Fast Python folding
7374
- Virtualenv support
74-
- Search by Python documentation and run Python code
75+
- Search through Python documentation and run Python code
7576
- Auto PEP8_ error fixes
7677

7778
And more.
7879

80+
SuperTab
81+
^^^^^^^^
82+
83+
SuperTab_ is a small Vim plugin that makes code completion more convenient by
84+
using ``<Tab>`` key or any other customized keys.
85+
7986
.. _indent: http://www.vim.org/scripts/script.php?script_id=974
8087
.. _syntax: http://www.vim.org/scripts/script.php?script_id=790
8188
.. _Pyflakes: http://pypi.python.org/pypi/pyflakes/
@@ -84,15 +91,14 @@ And more.
8491
.. _vim-pep8: https://github.com/nvie/vim-pep8
8592
.. _syntastic: https://github.com/scrooloose/syntastic
8693
.. _Python-mode: https://github.com/klen/python-mode
87-
88-
.. todo:: add supertab notes
94+
.. _SuperTab: http://www.vim.org/scripts/script.php?script_id=1643
8995

9096
Emacs
9197
-----
9298

93-
Emacs is a powerful text editor. It's fully programmable (lisp), but
94-
it can be some work to wire up correctly. A good start if you're
95-
already an Emacs user is `Python Programming in Emacs`_ at EmacsWiki.
99+
Emacs is another powerful text editor. It is fully programmable (lisp), but
100+
it can be some work to wire up correctly. A good start if you're already an
101+
Emacs user is `Python Programming in Emacs`_ at EmacsWiki.
96102

97103
1. Emacs itself comes with a Python mode.
98104
2. Python ships with an alternate version:
@@ -121,6 +127,17 @@ Sublime Text has excellent support for editing Python code and uses Python for
121127
its plugin API. It also has a diverse variety of plugins, `some of which <https://github.com/SublimeLinter/SublimeLinter>`_
122128
allow for in-editor PEP8 checking and code "linting".
123129

130+
Atom
131+
----
132+
133+
`Atom <https://atom.io/>`_ is a hackable text editor for the 21st century,
134+
built on atom-shell, and based on everything we love about our favorite editors.
135+
136+
Atom is web native (HTML, CSS, JS), focusing on modular design and easy plugin development.
137+
It comes with native package control and plethora of packages. Recommended for Python
138+
development is `Linter <https://github.com/AtomLinter/Linter>`_ combined with
139+
`linter-flake8 <https://github.com/AtomLinter/linter-flake8>`_.
140+
124141

125142
IDEs
126143
::::
@@ -131,6 +148,8 @@ PyCharm / IntelliJ IDEA
131148
`PyCharm <http://www.jetbrains.com/pycharm/>`_ is developed by JetBrains, also
132149
known for IntelliJ IDEA. Both share the same code base and most of PyCharm's
133150
features can be brought to IntelliJ with the free `Python Plug-In <http://plugins.intellij.net/plugin/?id=631>`_.
151+
There are two versions of PyCharm: Professional Edition (Free 30-day trial)
152+
and Community Edition(Apache 2.0 License) with fewer features.
134153

135154

136155
Eclipse
@@ -142,27 +161,30 @@ The most popular Eclipse plugin for Python development is Aptana's
142161

143162
Komodo IDE
144163
----------
164+
145165
`Komodo IDE <http://www.activestate.com/komodo-ide>`_ is developed by
146166
ActiveState and is a commercial IDE for Windows, Mac, and Linux.
167+
`KomodoEdit <https://github.com/Komodo/KomodoEdit>`_ is the open source
168+
alternative.
147169

148170

149171
Spyder
150172
------
151173

152174
`Spyder <http://code.google.com/p/spyderlib/>`_ is an IDE specifically geared
153175
toward working with scientific Python libraries (namely `Scipy <http://www.scipy.org/>`_).
154-
It includes integration with pyflakes_, `pylint <http://www.logilab.org/857>`_,
176+
It includes integration with pyflakes_, `pylint <http://www.logilab.org/857>`_
155177
and `rope <http://rope.sourceforge.net/>`_.
156178

157179
Spyder is open-source (free), offers code completion, syntax highlighting,
158-
class and function browser, and object inspection.
180+
a class and function browser, and object inspection.
159181

160182

161183
WingIDE
162184
-------
163185

164186
`WingIDE <http://wingware.com/>`_ is a Python specific IDE. It runs on Linux,
165-
Windows, and Mac (as an X11 application, which frustrates some Mac users).
187+
Windows and Mac (as an X11 application, which frustrates some Mac users).
166188

167189
WingIDE offers code completion, syntax highlighting, source browser, graphical
168190
debugger and support for version control systems.
@@ -179,116 +201,35 @@ systems. Installers for these platforms can be downloaded from the website.
179201
NINJA-IDE is open-source software (GPLv3 licence) and is developed in Python and
180202
Qt. The source files can be downloaded from `GitHub <https://github.com/ninja-ide>`_.
181203

182-
Interpreter Tools
183-
:::::::::::::::::
184-
185-
186-
virtualenv
187-
----------
188-
189-
Virtualenv is a tool to keep the dependencies required by different projects
190-
in separate places, by creating virtual Python environments for them.
191-
It solves the "Project X depends on version 1.x but, Project Y needs 4.x"
192-
dilemma, and keeps your global site-packages directory clean and manageable.
193-
194-
`virtualenv <http://www.virtualenv.org/en/latest/index.html>`_ creates
195-
a folder which contains all the necessary executables to contain the
196-
packages that a Python project would need. An example workflow is given.
197-
198-
Install virtualenv:
199-
200-
.. code-block:: console
201-
202-
$ pip install virtualenv
203-
204204

205-
Create a virtual environment for a project:
206-
207-
.. code-block:: console
208-
209-
$ cd my_project
210-
$ virtualenv venv
211-
212-
``virtualenv venv`` will create a folder in the current directory
213-
which will contain the Python executable files, and a copy of the ``pip``
214-
library which you can use to install other packages. The name of the
215-
virtual environment (in this case, it was ``venv``) can be anything;
216-
omitting the name will place the files in the current directory instead.
217-
218-
To start using the virtual environment, run:
219-
220-
.. code-block:: console
205+
Eric (The Eric Python IDE)
206+
--------------------------
221207

222-
$ source venv/bin/activate
208+
`Eric <http://eric-ide.python-projects.org/>`_ is a full featured Python IDE
209+
offering sourcecode autocompletion, syntax highlighting, support for version
210+
control systems, python 3 support, integrated web browser, python shell,
211+
integrated debugger and a flexible plug-in system. Written in python, it is
212+
based on the Qt gui toolkit, integrating the Scintilla editor control. Eric
213+
is an open-source software project (GPLv3 licence) with more than ten years of active
214+
development.
223215

224216

225-
The name of the current virtual environment will now appear on the left
226-
of the prompt (e.g. ``(venv)Your-Computer:your_project UserName$``) to
227-
let you know that it's active. From now on, any package that you install
228-
using ``pip`` will be placed in the ``venv`` folder, isolated from the global
229-
Python installation.
230-
231-
Install packages as usual:
232-
233-
.. code-block:: console
234-
235-
$ pip install requests
236-
237-
To stop using an environment, simply type ``deactivate``. To remove the
238-
environment, just remove the directory it was installed into. (In this
239-
case, it would be ``rm -rf venv``.)
240-
241-
Other Notes
242-
^^^^^^^^^^^
243-
244-
Running ``virtualenv`` with the option :option:`--no-site-packages` will not
245-
include the packages that are installed globally. This can be useful
246-
for keeping the package list clean in case it needs to be accessed later.
247-
[This is the default behavior for ``virtualenv`` 1.7 and later.]
248-
249-
In order to keep your environment consistent, it's a good idea to "freeze"
250-
the current state of the environment packages. To do this, run
251-
252-
.. code-block:: console
253-
254-
$ pip freeze > requirements.txt
255-
256-
This will create a :file:`requirements.txt` file, which contains a simple
257-
list of all the packages in the current environment, and their respective
258-
versions. Later, when a different developer (or you, if you need to re-
259-
create the environment) can install the same packages, with the same
260-
versions by running
261-
262-
.. code-block:: console
263-
264-
$ pip install -r requirements.txt
265-
266-
This can help ensure consistency across installations, across deployments,
267-
and across developers.
268-
269-
Lastly, remember to exclude the virtual environment folder from source
270-
control by adding it to the ignore list.
271-
272-
virtualenvwrapper
273-
-----------------
274-
275-
`Virtualenvwrapper <http://pypi.python.org/pypi/virtualenvwrapper>`_ makes
276-
virtualenv a pleasure to use by wrapping the command line API with a nicer CLI.
277-
278-
.. code-block:: console
279-
280-
$ pip install virtualenvwrapper
217+
Interpreter Tools
218+
:::::::::::::::::
281219

282220

283-
Put this into your :file:`~/.bash_profile` (Linux/Mac) file:
221+
Virtual Environments
222+
--------------------
284223

285-
.. code-block:: console
224+
A Virtual Environment is a tool to keep the dependencies required by different projects
225+
in separate places, by creating virtual Python environments for them. It solves the
226+
"Project X depends on version 1.x but, Project Y needs 4.x" dilemma, and keeps
227+
your global site-packages directory clean and manageable.
286228

287-
$ export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
229+
For example, you can work on a project which requires Django 1.3 while also
230+
maintaining a project which requires Django 1.0.
288231

289-
This will prevent your virtualenvs from relying on your (global) site packages
290-
directory, so that they are completely separate..
291-
[note: This is the default behavior for ``virtualenv`` 1.7 and later]
232+
To start using and see more information: `Virtual Environments <http://github.com/kennethreitz/python-guide/blob/master/docs/dev/virtualenvs.rst>`_ docs.
292233

293234
Other Tools
294235
:::::::::::
@@ -346,4 +287,3 @@ Python interpreter for Unix-like operating systems. It has the following feature
346287
.. code-block:: console
347288
348289
$ pip install bpython
349-

0 commit comments

Comments
 (0)