Conventions header was throwing inconsistent level warning. Fixed this and later headings to match rest of page.

This commit is contained in:
Andrew Macgregor
2012-10-16 22:21:32 +08:00
parent d8bc875813
commit f0834bcfaf
+6 -6
View File
@@ -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
@@ -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``.
@@ -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>`_
@@ -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.
@@ -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