mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 06:46:17 +00:00
Minor Polishes
This commit is contained in:
@@ -199,7 +199,7 @@ Ansible
|
||||
*******
|
||||
|
||||
`Ansible <http://ansible.com/>`_ is an open source system automation tool.
|
||||
The biggest advantage over Puppet or Chef is it does not require an agent on
|
||||
Its biggest advantage over Puppet or Chef is that it does not require an agent on
|
||||
the client machine. Playbooks are Ansible’s configuration, deployment, and
|
||||
orchestration language and are written in YAML with Jinja2 for templating.
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ Travis-CI
|
||||
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 hosting your code on GitHub, Travis-CI is a great
|
||||
build or not. So, if you are hosting your code on GitHub, Travis-CI is a great
|
||||
and easy way to get started with Continuous Integration.
|
||||
|
||||
In order to get started, add a :file:`.travis.yml` file to your repository with
|
||||
|
||||
@@ -31,7 +31,7 @@ Recommendations
|
||||
***************
|
||||
|
||||
|
||||
.. note:: The use of **Python 3** is *highly* preferred over Python 2. Consider upgrading your applications and infrastructure if you find yourself *still* using Python 2 in production today. If you are using Python 3, congratulations — you are indeed a person of excellent taste.
|
||||
.. note:: The use of **Python 3** is *highly* recommended over Python 2. Consider upgrading your applications and infrastructure if you find yourself *still* using Python 2 in production today. If you are using Python 3, congratulations — you are indeed a person of excellent taste.
|
||||
—*Kenneth Reitz*
|
||||
|
||||
I'll be blunt:
|
||||
|
||||
@@ -226,7 +226,7 @@ but making a public property private might be a much harder operation.
|
||||
Returning values
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
When a function grows in complexity it is not uncommon to use multiple return
|
||||
When a function grows in complexity, it is not uncommon to use multiple return
|
||||
statements inside the function's body. However, in order to keep a clear intent
|
||||
and a sustainable readability level, it is preferable to avoid returning
|
||||
meaningful values from many output points in the body.
|
||||
@@ -639,11 +639,11 @@ Short Ways to Manipulate Lists
|
||||
|
||||
`List comprehensions
|
||||
<http://docs.python.org/tutorial/datastructures.html#list-comprehensions>`_
|
||||
provide a powerful, concise way to work with lists.
|
||||
provides a powerful, concise way to work with lists.
|
||||
|
||||
`Generator expressions
|
||||
<http://docs.python.org/tutorial/classes.html#generator-expressions>`_
|
||||
follow almost the same syntax as list comprehensions but return a generator
|
||||
follows almost the same syntax as list comprehensions but return a generator
|
||||
instead of a list.
|
||||
|
||||
Creating a new list requires more work and uses more memory. If you are just going
|
||||
@@ -829,7 +829,7 @@ a white space added to the end of the line, after the backslash, will break the
|
||||
code and may have unexpected results.
|
||||
|
||||
A better solution is to use parentheses around your elements. Left with an
|
||||
unclosed parenthesis on an end-of-line the Python interpreter will join the
|
||||
unclosed parenthesis on an end-of-line, the Python interpreter will join the
|
||||
next line until the parentheses are closed. The same behavior holds for curly
|
||||
and square braces.
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ Testing Your Code
|
||||
Testing your code is very important.
|
||||
|
||||
Getting used to writing testing code and running this code in parallel is now
|
||||
considered a good habit. Used wisely, this method helps you define more
|
||||
precisely your code's intent and have a more decoupled architecture.
|
||||
considered a good habit. Used wisely, this method helps to define your
|
||||
code's intent more precisely and have a more decoupled architecture.
|
||||
|
||||
Some general rules of testing:
|
||||
|
||||
@@ -294,6 +294,6 @@ always returns the same result (but only for the duration of the test).
|
||||
# get_search_results runs a search and iterates over the result
|
||||
self.assertEqual(len(myapp.get_search_results(q="fish")), 3)
|
||||
|
||||
Mock has many other ways you can configure it and control its behavior.
|
||||
Mock has many other ways with which you can configure and control its behaviour.
|
||||
|
||||
`mock <http://www.voidspace.org.uk/python/mock/>`_
|
||||
|
||||
Reference in New Issue
Block a user