Skip to content

Commit ad28c33

Browse files
committed
they see me stylin'
1 parent f829b31 commit ad28c33

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

docs/writing/style.rst

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ Instead, use a list comprehension:
350350
.. code-block:: python
351351
352352
four_lists = [[] for __ in xrange(4)]
353-
353+
354354
Note: Use range() instead of xrange() in Python 3
355355

356356
Create a string from a list
@@ -389,29 +389,29 @@ Take the following code for example:
389389
Even though both functions look identical, because *lookup_set* is utilizing
390390
the fact that sets in Python are hashtables, the lookup performance
391391
between the two is very different. To determine whether an item is in a list,
392-
Python will have to go through each item until it finds a matching item.
392+
Python will have to go through each item until it finds a matching item.
393393
This is time consuming, especially for long lists. In a set, on the other
394394
hand, the hash of the item will tell Python where in the set to look for
395395
a matching item. As a result, the search can be done quickly, even if the
396-
set is large. Searching in dictionaries works the same way. For
396+
set is large. Searching in dictionaries works the same way. For
397397
more information see this
398398
`StackOverflow <http://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table>`_
399399
page. For detailed information on the amount of time various common operations
400-
take on each of these data structures, see
400+
take on each of these data structures, see
401401
`this page <https://wiki.python.org/moin/TimeComplexity?>`_.
402402

403-
Because of these differences in performance, it is often a good idea to use
404-
sets or dictionaries instead of lists in cases where:
403+
Because of these differences in performance, it is often a good idea to use
404+
sets or dictionaries instead of lists in cases where:
405405

406406
* The collection will contain a large number of items
407407

408408
* You will be repeatedly searching for items in the collection
409409

410-
* You do not have duplicate items.
410+
* You do not have duplicate items.
411411

412-
For small collections, or collections which you will not frequently be
413-
searching through, the additional time and memory required to set up the
414-
hashtable will often be greater than the time saved by the improved search
412+
For small collections, or collections which you will not frequently be
413+
searching through, the additional time and memory required to set up the
414+
hashtable will often be greater than the time saved by the improved search
415415
speed.
416416

417417

@@ -451,11 +451,17 @@ group <http://artifex.org/~hblanks/talks/2011/pep20_by_example.pdf>`_.
451451
PEP 8
452452
-----
453453

454-
:pep:`8` is the de-facto code style guide for Python.
454+
:pep:`8` is the de-facto code style guide for Python. A high quality,
455+
easy-to-read version of PEP 8 is also available at `pep8.org <http://pep8.org/>`_.
456+
457+
This is highly recommended reading. The entire Python community does their
458+
best to adhere to the guidelines laidout within this document. Some project
459+
may sway from it from time to time, while others may
460+
`ammend its recommendations <http://docs.python-requests.org/en/master/dev/contributing/#kenneth-reitz-s-code-style>`_.
455461

456-
Conforming your Python code to PEP 8 is generally a good idea and helps make
457-
code more consistent when working on projects with other developers. There
458-
is a command-line program, `pep8 <https://github.com/jcrocholl/pep8>`_,
462+
That being said, conforming your Python code to PEP 8 is generally a good
463+
idea and helps make code more consistent when working on projects with other
464+
developers. There is a command-line program, `pep8 <https://github.com/jcrocholl/pep8>`_,
459465
that can check your code for conformance. Install it by running the following
460466
command in your terminal:
461467

0 commit comments

Comments
 (0)