mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 14:50:19 +00:00
Wording, comma and case changes (VIM->Vim) for dev/env.
Tried to normalize with no Oxford commas.
This commit is contained in:
+27
-24
@@ -5,15 +5,15 @@ Your Development Environment
|
||||
Text Editors
|
||||
::::::::::::
|
||||
|
||||
Just about anything which can edit plain text will work for writing Python code,
|
||||
Just about anything that can edit plain text will work for writing Python code,
|
||||
however, using a more powerful editor may make your life a bit easier.
|
||||
|
||||
|
||||
VIM
|
||||
Vim
|
||||
---
|
||||
|
||||
Vim is a text editor which uses keyboard shortcuts for editing instead of menus
|
||||
or icons. There exist a couple of plugins and settings for the VIM editor to
|
||||
or icons. There are a couple of plugins and settings for the Vim editor to
|
||||
aid Python development. If you only develop in Python, a good start is to set
|
||||
the default settings for indentation and line-wrapping to values compliant with
|
||||
:pep:`8`. In your home directory, open a file called :file:`.vimrc` and add the
|
||||
@@ -21,24 +21,24 @@ following lines::
|
||||
|
||||
set textwidth=79 " lines longer than 79 columns will be broken
|
||||
set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns
|
||||
set tabstop=4 " an hard TAB displays as 4 columns
|
||||
set tabstop=4 " a hard TAB displays as 4 columns
|
||||
set expandtab " insert spaces when hitting TABs
|
||||
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE
|
||||
set shiftround " round indent to multiple of 'shiftwidth'
|
||||
set autoindent " align the new line indent with the previous line
|
||||
|
||||
With these settings, newlines are inserted after 79 characters and indentation
|
||||
is set to 4 spaces per tab. If you also use VIM for other languages, there is a
|
||||
handy plugin at indent_, which handles indentation settings for Python source
|
||||
is set to 4 spaces per tab. If you also use Vim for other languages, there is a
|
||||
handy plugin called indent_, which handles indentation settings for Python source
|
||||
files.
|
||||
|
||||
There is also a handy syntax plugin at syntax_ featuring some improvements over
|
||||
the syntax file included in VIM 6.1.
|
||||
There is also a handy syntax plugin called syntax_ featuring some improvements over
|
||||
the syntax file included in Vim 6.1.
|
||||
|
||||
These plugins supply you with a basic environment for developing in Python.
|
||||
To get the most out of Vim, you should continually check your code for syntax
|
||||
errors and PEP8 compliance. Luckily PEP8_ and Pyflakes_ will do this for you.
|
||||
If your VIM is compiled with :option:`+python` you can also utilize some very handy
|
||||
If your Vim is compiled with :option:`+python` you can also utilize some very handy
|
||||
plugins to do these checks from within the editor.
|
||||
|
||||
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`::
|
||||
autocmd BufWritePost *.py call Pyflakes()
|
||||
autocmd BufWritePost *.py call Pep8()
|
||||
|
||||
If you are already using syntastic_ you can enable it to run Pyflakes on write
|
||||
If you are already using syntastic_, you can tell it to run Pyflakes on write
|
||||
and show errors and warnings in the quickfix window. An example configuration
|
||||
to do that which also shows status and warning messages in the statusbar would be::
|
||||
|
||||
@@ -61,24 +61,26 @@ to do that which also shows status and warning messages in the statusbar would b
|
||||
let g:syntastic_auto_loc_list=1
|
||||
let g:syntastic_loc_list_height=5
|
||||
|
||||
|
||||
Python-mode
|
||||
^^^^^^^^^^^
|
||||
|
||||
Python-mode_ is a complex solution in VIM for working with Python code.
|
||||
Python-mode_ is a complex solution for working with Python code in Vim.
|
||||
It has:
|
||||
|
||||
- Asynchronous Python code checking (``pylint``, ``pyflakes``, ``pep8``, ``mccabe``) in any combination
|
||||
- Code refactoring and autocompletion with Rope
|
||||
- Fast Python folding
|
||||
- Virtualenv support
|
||||
- Search by Python documentation and run Python code
|
||||
- Search through Python documentation and run Python code
|
||||
- Auto PEP8_ error fixes
|
||||
|
||||
And more.
|
||||
|
||||
SuperTab
|
||||
^^^^^^^^
|
||||
SuperTab_ is a small VIM plugin that makes code completion more convenient by
|
||||
|
||||
SuperTab_ is a small Vim plugin that makes code completion more convenient by
|
||||
using ``<Tab>`` key or any other customized keys.
|
||||
|
||||
.. _indent: http://www.vim.org/scripts/script.php?script_id=974
|
||||
@@ -94,9 +96,9 @@ using ``<Tab>`` key or any other customized keys.
|
||||
Emacs
|
||||
-----
|
||||
|
||||
Emacs is a powerful text editor. It's fully programmable (lisp), but
|
||||
it can be some work to wire up correctly. A good start if you're
|
||||
already an Emacs user is `Python Programming in Emacs`_ at EmacsWiki.
|
||||
Emacs is another powerful text editor. It is fully programmable (lisp), but
|
||||
it can be some work to wire up correctly. A good start if you're already an
|
||||
Emacs user is `Python Programming in Emacs`_ at EmacsWiki.
|
||||
|
||||
1. Emacs itself comes with a Python mode.
|
||||
2. Python ships with an alternate version:
|
||||
@@ -155,18 +157,18 @@ Spyder
|
||||
|
||||
`Spyder <http://code.google.com/p/spyderlib/>`_ is an IDE specifically geared
|
||||
toward working with scientific Python libraries (namely `Scipy <http://www.scipy.org/>`_).
|
||||
It includes integration with pyflakes_, `pylint <http://www.logilab.org/857>`_,
|
||||
It includes integration with pyflakes_, `pylint <http://www.logilab.org/857>`_
|
||||
and `rope <http://rope.sourceforge.net/>`_.
|
||||
|
||||
Spyder is open-source (free), offers code completion, syntax highlighting,
|
||||
class and function browser, and object inspection.
|
||||
a class and function browser and object inspection.
|
||||
|
||||
|
||||
WingIDE
|
||||
-------
|
||||
|
||||
`WingIDE <http://wingware.com/>`_ is a Python specific IDE. It runs on Linux,
|
||||
Windows, and Mac (as an X11 application, which frustrates some Mac users).
|
||||
Windows and Mac (as an X11 application, which frustrates some Mac users).
|
||||
|
||||
WingIDE offers code completion, syntax highlighting, source browser, graphical
|
||||
debugger and support for version control systems.
|
||||
@@ -196,8 +198,9 @@ It solves the "Project X depends on version 1.x but, Project Y needs 4.x"
|
||||
dilemma, and keeps your global site-packages directory clean and manageable.
|
||||
|
||||
`virtualenv <http://www.virtualenv.org/en/latest/index.html>`_ creates
|
||||
a folder which contains all the necessary executables to contain the
|
||||
packages that a Python project would need. An example workflow is given.
|
||||
a folder which contains all the necessary executables to use the
|
||||
packages that a Python project would need. An example workflow is given
|
||||
below.
|
||||
|
||||
Install virtualenv:
|
||||
|
||||
@@ -259,7 +262,7 @@ the current state of the environment packages. To do this, run
|
||||
|
||||
This will create a :file:`requirements.txt` file, which contains a simple
|
||||
list of all the packages in the current environment, and their respective
|
||||
versions. Later, when a different developer (or you, if you need to re-
|
||||
versions. Later, a different developer (or you, if you need to re-
|
||||
create the environment) can install the same packages, with the same
|
||||
versions by running
|
||||
|
||||
@@ -291,8 +294,8 @@ Put this into your :file:`~/.bash_profile` (Linux/Mac) file:
|
||||
$ export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
|
||||
|
||||
This will prevent your virtualenvs from relying on your (global) site packages
|
||||
directory, so that they are completely separate..
|
||||
[note: This is the default behavior for ``virtualenv`` 1.7 and later]
|
||||
directory, so that they are completely separate.
|
||||
[Note: This is the default behavior for ``virtualenv`` 1.7 and later]
|
||||
|
||||
Other Tools
|
||||
:::::::::::
|
||||
|
||||
Reference in New Issue
Block a user