Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/intro/community.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _the_community:
.. _the-community:

The Community
=============
Expand Down
4 changes: 2 additions & 2 deletions docs/intro/learning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ Python Koans

Python Koans is a port of Edgecase's Ruby Koans. It uses a test-driven
approach, q.v. TEST DRIVEN DESIGN SECTION to provide an interactive tutorial
teaching basic python concepts. By fixing assertion statements that fail in a
test script, this provides sequential steps to learning python.
teaching basic python concepts. By fixing assertion statements that fail in a
test script, this provides sequential steps to learning python.

For those used to languages and figuring out puzzles on their own, this can be
a fun, attractive option. For those new to python and programming, having an
Expand Down
4 changes: 2 additions & 2 deletions docs/scenarios/db.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Nearly all Python database modules such as `sqlite3`, `psycopg` and
`mysql-python` conform to this interface.

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://halfcooked.com/presentations/osdc2006/python_databases.html>`__ and
`here <http://www.amk.ca/python/writing/DB-API.html>`__.

SQLAlchemy
----------
Expand Down
2 changes: 2 additions & 0 deletions docs/starting/which-python.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Picking an Interpreter
======================

.. _which-python:

Which Python to use?


Expand Down
2 changes: 1 addition & 1 deletion docs/writing/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ logic (called pure functions) allow the following benefits:
- Pure functions are easier to test with unit-tests: There is less
need for complex context setup and data cleaning afterwards.

- Pure functions are easier to manipulate, decorate_, and pass-around.
- Pure functions are easier to manipulate, decorate, and pass-around.

In summary, pure functions, without any context or side-effects, are more
efficient building blocks than classes and objects for some architectures.
Expand Down
20 changes: 10 additions & 10 deletions docs/writing/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ Those two possibilities are better avoided without any strong reason to not
follow the syntax that is the closest to the function definition: ``send('Hello',
'World', cc='Cthulhu', bcc='God')``.

As a side note, following YAGNI_ principle, it is often harder to remove an
optional argument (and its logic inside the function) that was added "just in
case" and is seemingly never used, than to add a new optional argument and its
logic when needed.
As a side note, following `YAGNI <http://en.wikipedia.org/wiki/You_ain't_gonna_need_it>`_
principle, it is often harder to remove an optional argument (and its logic inside the
function) that was added "just in case" and is seemingly never used, than to add a
new optional argument and its logic when needed.

The **arbitrary argument list** is the third way to pass arguments to a
function. If the function intention is better expressed by a signature with an
Expand Down Expand Up @@ -416,12 +416,12 @@ Then run it on a file or series of files to get a report of any violations.
optparse.py:544:21: W601 .has_key() is deprecated, use 'in'

Conventions
:::::::::::
----------------

Here are some conventions you should follow to make your code easier to read.

Check if variable equals a constant
-----------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You don't need to explicitly compare a value to True, or None, or 0 - you can
just add it to the if statement. See `Truth Value Testing
Expand Down Expand Up @@ -455,7 +455,7 @@ list of what is considered false.
print 'attr is None!'

Access a Dictionary Element
---------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Don't use the ``has_key`` function. Instead use ``x in d`` syntax, or pass
a default argument to ``get``.
Expand Down Expand Up @@ -484,7 +484,7 @@ a default argument to ``get``.
print d['hello']

Short Ways to Manipulate Lists
------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`List comprehensions
<http://docs.python.org/tutorial/datastructures.html#list-comprehensions>`_
Expand Down Expand Up @@ -548,7 +548,7 @@ manually. Moreover,
it is better optimized for iterators.

Read From a File
----------------
~~~~~~~~~~~~~~~~

Use the ``with open`` syntax to read from files. This will automatically close
files for you.
Expand All @@ -574,7 +574,7 @@ The ``with`` statement is better because it will ensure you always close the
file, even if an exception is raised.

Returning Multiple Values from a Function
-----------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Python supports returning multiple values from a function as a comma-separated
list, so you don't have to create an object or dictionary and pack multiple
Expand Down