mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -60,7 +60,7 @@ where they were placed.
|
||||
virtualenvwrapper
|
||||
-----------------
|
||||
|
||||
`virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/>`_
|
||||
`virtualenvwrapper <http://virtualenvwrapper.readthedocs.org/en/latest/index.html>`_
|
||||
provides a set of commands which makes working with virtual environments much
|
||||
more pleasant. It also places all your virtual environments in one place.
|
||||
|
||||
@@ -72,7 +72,7 @@ To install (make sure **virtualenv** is already installed):
|
||||
$ export WORKON_HOME=~/Envs
|
||||
$ source /usr/local/bin/virtualenvwrapper.sh
|
||||
|
||||
(`Full virtualenvwrapper install instructions <http://www.doughellmann.com/docs/virtualenvwrapper/#introduction>`_.)
|
||||
(`Full virtualenvwrapper install instructions <http://virtualenvwrapper.readthedocs.org/en/latest/install.html>`_.)
|
||||
|
||||
For Windows, you can use the `virtualenvwrapper-powershell <https://bitbucket.org/guillermooo/virtualenvwrapper-powershell>`_ clone.
|
||||
|
||||
@@ -136,7 +136,7 @@ Other useful commands
|
||||
``lssitepackages``
|
||||
Shows contents of ``site-packages`` directory.
|
||||
|
||||
`Full list of virtualenvwrapper commands <http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html#managing-environments>`_.
|
||||
`Full list of virtualenvwrapper commands <http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html>`_.
|
||||
|
||||
autoenv
|
||||
-------
|
||||
|
||||
@@ -6,7 +6,7 @@ Official Documentation
|
||||
|
||||
The official Python Language and Library documentation can be found here:
|
||||
|
||||
- `Python 2.x <http://docs.python.org/>`_
|
||||
- `Python 2.x <http://docs.python.org/2.7/>`_
|
||||
- `Python 3.x <http://docs.python.org/py3k/>`_
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ A free introductory book that teaches python at the beginner level, it assumes n
|
||||
previous programming experience.
|
||||
|
||||
`A Byte of Python for Python 2.x <http://www.ibiblio.org/swaroopch/byteofpython/read/>`_
|
||||
`A Byte of Python for Python 3.x <http://www.swaroopch.org/notes/Python_en:Table_of_Contents>`_
|
||||
`A Byte of Python for Python 3.x <http://swaroopch.com/notes/Python_en-Preface/>`_
|
||||
|
||||
|
||||
Advanced
|
||||
@@ -160,6 +160,8 @@ Python in a Nutshell, written by Alex Martelli, covers most cross-platform
|
||||
python's usage, from its syntax to built-in libraries to advanced topics such
|
||||
as writing C extensions.
|
||||
|
||||
`Python in a Nutshell <http://shop.oreilly.com/product/9780596001889.do>`_
|
||||
|
||||
The Python Language Reference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ engine. Use it.
|
||||
|
||||
Buildbot
|
||||
--------
|
||||
`Buildbot <http://buildbot.net/buildbot/docs/current>`_ is a Python system to
|
||||
`Buildbot <http://docs.buildbot.net/current/>`_ is a Python system to
|
||||
automate the compile/test cycle to validate code changes.
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ Mule?
|
||||
Tox
|
||||
---
|
||||
|
||||
`tox <https://bitbucket.org/hpk42/tox>`_ is an automation tool providing
|
||||
`tox <http://tox.readthedocs.org/en/latest/>`_ is an automation tool providing
|
||||
packaging, testing and deployment of Python software right from the console or
|
||||
CI server. It is a generic virtualenv management and test command line tool
|
||||
which provides the following features:
|
||||
@@ -53,7 +53,7 @@ which provides the following features:
|
||||
|
||||
Travis-CI
|
||||
---------
|
||||
`Travis-CI <http://travis-ci.org/>`_ is a distributed CI server which builds tests
|
||||
`Travis-CI <https://travis-ci.org/>`_ is a distributed CI server which builds tests
|
||||
for open source projects for free. It provides multiple workers to run Python tests
|
||||
on and seamlessly integrates with Github. You can even have it comment on your Pull
|
||||
Requests whether this particular changeset breaks the build or not. So if you are
|
||||
@@ -83,6 +83,6 @@ notifications, before and after steps and much more. The
|
||||
`travis-ci docs <http://about.travis-ci.org/docs/>`_ explain all of those and are very
|
||||
thorough.
|
||||
|
||||
In order to activate testing for your project, go to `the travis-ci site <http://travis-ci.org/>`_
|
||||
In order to activate testing for your project, go to `the travis-ci site <https://travis-ci.org/>`_
|
||||
and login with your Github account. Then activate your project in your profile settings and that's
|
||||
it. From now on, your project's tests will be run on every push to Github.
|
||||
it. From now on, your project's tests will be run on every push to Github.
|
||||
|
||||
@@ -11,7 +11,7 @@ Nearly all Python database modules such as `sqlite3`, `psycopg` and
|
||||
|
||||
Tutorials that explain how to work with modules that conform to this interface can be found
|
||||
`here <http://halfcooked.com/presentations/osdc2006/python_databases.html>`__ and
|
||||
`here <http://www.amk.ca/python/writing/DB-API.html>`__.
|
||||
`here <http://web.archive.org/web/20120815130844/http://www.amk.ca/python/writing/DB-API.html>`__.
|
||||
|
||||
SQLAlchemy
|
||||
----------
|
||||
|
||||
+14
-1
@@ -4,7 +4,7 @@ GUI Applications
|
||||
|
||||
Qt
|
||||
--
|
||||
Qt is a cross-platform application framework that is widely used for developing
|
||||
`Qt <http://qt-project.org/>`_ is a cross-platform application framework that is widely used for developing
|
||||
software with a GUI but can also be used for non-GUI applications.
|
||||
|
||||
PySide
|
||||
@@ -87,3 +87,16 @@ source code to be executed as a standalone desktop application.
|
||||
`Python Wiki for PyjamasDesktop <http://wiki.python.org/moin/PyjamasDesktop>`_.
|
||||
|
||||
The main website; `pyjs Desktop <http://pyjs.org/>`_.
|
||||
|
||||
Camelot
|
||||
-------
|
||||
`Camelot <http://www.python-camelot.com>`_ provides components for building
|
||||
business applications on top of Python, SQLAlchemy and Qt. It is inspired by
|
||||
the Django admin interface.
|
||||
|
||||
You can use Camelot to develop both simple and complex business applications
|
||||
at warp speed.
|
||||
|
||||
The main resource for information is the website:
|
||||
http://www.python-camelot.com
|
||||
and the mailinglist https://groups.google.com/forum/#!forum/project-camelot
|
||||
|
||||
@@ -92,7 +92,7 @@ Support can be found on its `mailing list <http://werkzeug.pocoo.org/community/#
|
||||
|
||||
Tornado
|
||||
--------
|
||||
`Tornado <http://http://www.tornadoweb.org/>`_ is a scalable, non-blocking web server and web application framework with
|
||||
`Tornado <http://www.tornadoweb.org/>`_ is a scalable, non-blocking web server and web application framework with
|
||||
a relative simple usage. Tornado is known for his high performance.
|
||||
It was initially developed for `friendfeed <http://friendfeed.com/>`_ , a real time chat and blog system.
|
||||
|
||||
@@ -152,7 +152,7 @@ lightweight, easy to use, and uses many UNIX idioms. Gunicorn is not designed
|
||||
to face the internet -- it was designed to run behind Nginx which buffers
|
||||
slow requests and takes care of other important considerations. A sample
|
||||
setup for Nginx + Gunicorn can be found in the
|
||||
`Gunicorn help <http://gunicorn.org/deploy.html>`_.
|
||||
`Gunicorn help <http://gunicorn.org/index.html#deployment>`_.
|
||||
|
||||
.. _uwsgi-ref:
|
||||
|
||||
@@ -235,9 +235,7 @@ and Pinax applications. Gondor supports Django versions 1.2 and 1.3 on
|
||||
Python version 2.7, and can automatically configure your Django site if you
|
||||
use ``local_settings.py`` for site-specific configuration information.
|
||||
|
||||
Gondor publishes guides to deploying `Django projects
|
||||
<https://gondor.io/support/setting-up-django/>`_ and `Pinax projects
|
||||
<https://gondor.io/support/setting-up-pinax/>`_ on their platform.
|
||||
Gondor has a guide on deploying `Django projects <https://gondor.io/support/django/setup/>`_.
|
||||
|
||||
|
||||
Templating
|
||||
|
||||
@@ -32,3 +32,42 @@ and then you can get the child elements name like this:
|
||||
|
||||
untangle also supports loading XML from a string or an URL.
|
||||
|
||||
xmltodict
|
||||
---------
|
||||
|
||||
`xmltodict <http://github.com/martinblech/xmltodict>`_ is another simple
|
||||
library that aims at making xml feel like working with json.
|
||||
|
||||
An xml file like this:
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<mydocument has="an attribute">
|
||||
<and>
|
||||
<many>elements</many>
|
||||
<many>more elements</many>
|
||||
</and>
|
||||
<plus a="complex">
|
||||
element as well
|
||||
</plus>
|
||||
</mydocument>
|
||||
|
||||
can be loaded into a python dict like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import xmltodict
|
||||
obj = xmltodict.parse('path/to/file.xml')
|
||||
|
||||
and then you can access elements, attributes and values like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc['mydocument']['@has'] # == u'an attribute'
|
||||
doc['mydocument']['and']['many'] # == [u'elements', u'more elements']
|
||||
doc['mydocument']['plus']['@a'] # == u'complex'
|
||||
doc['mydocument']['plus']['#text'] # == u'element as well'
|
||||
|
||||
xmltodict also lets you roundtrip back to xml with the unparse function,
|
||||
has a streaming mode suitable for handling files that don't fit in memory
|
||||
and supports namespaces.
|
||||
|
||||
@@ -54,7 +54,7 @@ line at the bottom of your ``~/.bashrc`` file
|
||||
|
||||
Now, we can install Python 2.7: ::
|
||||
|
||||
$ brew install python --framework
|
||||
$ brew install python
|
||||
|
||||
This will take a minute or two. Once that's complete, you'll have to add the
|
||||
new Python scripts directory to your ``PATH``
|
||||
@@ -63,11 +63,6 @@ new Python scripts directory to your ``PATH``
|
||||
|
||||
export PATH=/usr/local/share/python:$PATH
|
||||
|
||||
The ``--framework`` option tells Homebrew to compile a Framework-style Python
|
||||
build, rather than a UNIX-style build. The outdated version of Python that
|
||||
Snow Leopard comes packaged with is built as a Framework, so this helps avoid
|
||||
some future module installation bugs.
|
||||
|
||||
|
||||
Distribute & Pip
|
||||
----------------
|
||||
|
||||
@@ -36,21 +36,21 @@ packages are installed, so it is a very useful addition.
|
||||
You do not need to install or configure anything else to use Python. Having
|
||||
said that, I would strongly recommend that you install the tools and libraries
|
||||
described in the next section before you start building Python applications for
|
||||
real-world use. In particular, you should always install Distribute, as it
|
||||
real-world use. In particular, you should always install Setuptools, as it
|
||||
makes it much easier for you to use other third-party Python libraries.
|
||||
|
||||
Distribute + Pip
|
||||
Setuptools + Pip
|
||||
----------------
|
||||
|
||||
The most crucial third-party Python software of all is Distribute, which
|
||||
The most crucial third-party Python software of all is Setuptools, which
|
||||
extends the packaging and installation facilities provided by the distutils in
|
||||
the standard library. Once you add Distribute to your Python system you can
|
||||
the standard library. Once you add Setuptools to your Python system you can
|
||||
download and install any compliant Python software product with a single
|
||||
command. It also enables you to add this network installation capability to
|
||||
your own Python software with very little work.
|
||||
|
||||
To obtain the latest version of Distribute for Windows, run the python script
|
||||
available here: `python-distribute <http://python-distribute.org/distribute_setup.py>`_
|
||||
To obtain the latest version of Setuptools for Windows, run the python script
|
||||
available here: `ez_setup.py <https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py>`_
|
||||
|
||||
|
||||
You'll now have a new command available to you: **easy_install**. It is
|
||||
@@ -58,11 +58,8 @@ considered by many to be deprecated, so we will install its replacement:
|
||||
**pip**. Pip allows for uninstallation of packages, and is actively maintained,
|
||||
unlike easy_install.
|
||||
|
||||
To install pip, simply open a command prompt and run
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
> easy_install pip
|
||||
To install pip, run the python script available here:
|
||||
`get-pip.py <https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_
|
||||
|
||||
|
||||
Virtualenv
|
||||
@@ -89,7 +86,7 @@ project's directory
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
> virtualenv --distribute venv
|
||||
> virtualenv venv
|
||||
|
||||
To use an environment, run the ``activate.bat`` batch file in the ``Scripts``
|
||||
subdirectory of that environment. Your command prompt will change to show the
|
||||
|
||||
@@ -273,7 +273,8 @@ Unpacking
|
||||
~~~~~~~~~
|
||||
|
||||
If you know the length of a list or tuple, you can assign names to its
|
||||
elements with unpacking:
|
||||
elements with unpacking. For example, since ``enumerate()`` will provide
|
||||
a tuple of two elements for each item in list:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
Reference in New Issue
Block a user