Skip to content

Commit 2568877

Browse files
committed
Merge pull request realpython#456 from george2/grammar-and-typos
Grammar and typo fixes
2 parents 63d836e + 9079873 commit 2568877

File tree

7 files changed

+59
-55
lines changed

7 files changed

+59
-55
lines changed

Readme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Topics include:
2626
- Server configurations & tools for various web frameworks
2727
- Documentation: writing it
2828
- Testing: Jenkins & tox guides
29-
- How to easily interface ``hg`` from ``git`` easily
29+
- How to easily interface ``hg`` from ``git``
3030

3131
If you aren't fond of reading reStructuredText, there is an
3232
almost up-to-date `HTML version at docs.python-guide.org

docs/writing/documentation.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ both you and others a lot of time.
88
Project Documentation
99
---------------------
1010

11-
A :file:`README` file at the root directory should give general
12-
information to the users and the maintainers. It should be raw text or
13-
written in some very easy to read markup, such as
14-
:ref:`reStructuredText-ref` and Markdown. It should contain a few
15-
lines explaining the purpose of the project or the library (without
16-
assuming the user knows anything about the project), the url of the
17-
main source for the software, and some basic credit information. This
18-
file is the main entry point for readers of the code.
11+
A :file:`README` file at the root directory should give general information
12+
to both users and maintainers of a project. It should be raw text or
13+
written in some very easy to read markup, such as :ref:`reStructuredText-ref`
14+
or Markdown. It should contain a few lines explaining the purpose of the
15+
project or library (without assuming the user knows anything about the
16+
project), the url of the main source for the software, and some basic credit
17+
information. This file is the main entry point for readers of the code.
1918

2019
An :file:`INSTALL` file is less necessary with Python. The installation
2120
instructions are often reduced to one command, such as ``pip install
2221
module`` or ``python setup.py install`` and added to the :file:`README`
2322
file.
2423

25-
A :file:`LICENSE` file should *always* be present and specify the license under which the
26-
software is made available to the public.
24+
A :file:`LICENSE` file should *always* be present and specify the license
25+
under which the software is made available to the public.
2726

2827
A :file:`TODO` file or a ``TODO`` section in :file:`README` should list the
2928
planned development for the code.
@@ -158,7 +157,8 @@ Pycco_
158157
.. _Docco: http://jashkenas.github.com/docco
159158

160159
Ronn_
161-
Ronn builds unix manuals. It converts human readable textfiles to roff for terminal display, and also to HTML for the web.
160+
Ronn builds unix manuals. It converts human readable textfiles to roff
161+
for terminal display, and also to HTML for the web.
162162

163163
.. _Ronn: https://github.com/rtomayko/ronn
164164

docs/writing/gotchas.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ signal that no argument was provided (:py:data:`None` is often a good choice).
7979
When the Gotcha Isn't a Gotcha
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8181

82-
Sometimes you specifically can "exploit" (read: use as intended) this behavior
82+
Sometimes you can specifically "exploit" (read: use as intended) this behavior
8383
to maintain state between calls of a function. This is often done when writing
8484
a caching function.
8585

@@ -126,7 +126,7 @@ What Does Happen
126126
8
127127
8
128128

129-
Five functions are created, but all of them just multiply ``x`` by 4.
129+
Five functions are created; instead all of them just multiply ``x`` by 4.
130130

131131
Python's closures are *late binding*.
132132
This means that the values of variables used in closures are looked

docs/writing/license.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Choosing a License
44
Your source publication *needs* a license. In the US, if no license is
55
specified, users have no legal right to download, modify, or
66
distribute. Furthermore, people can't contribute to your code unless
7-
you tell them what rules to play by. It's complicated, so here are
8-
some pointers:
7+
you tell them what rules to play by. Choosing a license is complicated, so
8+
here are some pointers:
99

1010
Open source. There are plenty of `open source licenses
1111
<http://opensource.org/licenses/alphabetical>`_ available to choose

docs/writing/structure.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ which is not the case. There is an
9999
`example <http://docs.python.org/tutorial/modules.html#packages>`_ of how the
100100
dot notation should be used in the Python docs.
101101

102-
If you'd like you could name it as :file:`my_spam.py` but even our friend the
103-
underscore should not be seen often in module names.
102+
If you'd like you could name your module :file:`my_spam.py`, but even our
103+
friend the underscore should not be seen often in module names.
104104

105-
Aside for some naming restrictions, nothing special is required for a Python file
106-
to be a module, but the import mechanism needs to be understood in order to use
107-
this concept properly and avoid some issues.
105+
Aside from some naming restrictions, nothing special is required for a Python
106+
file to be a module, but you need to understand the import mechanism in order
107+
to use this concept properly and avoid some issues.
108108

109109
Concretely, the ``import modu`` statement will look for the proper file, which is
110110
:file:`modu.py` in the same directory as the caller if it exists. If it is not
@@ -134,7 +134,7 @@ compartmentalized**.
134134
Using ``from modu import func`` is a way to pinpoint the function you want to
135135
import and put it in the global namespace. While much less harmful than ``import
136136
*`` because it shows explicitly what is imported in the global namespace, its
137-
advantage over a simpler ``import modu`` is only that it will save some typing.
137+
only advantage over a simpler ``import modu`` is that it will save a little typing.
138138

139139
**Very bad**
140140

@@ -161,11 +161,11 @@ advantage over a simpler ``import modu`` is only that it will save some typing.
161161
[...]
162162
x = modu.sqrt(4) # sqrt is visibly part of modu's namespace
163163
164-
As said in the section about style, readability is one of the main features of
165-
Python. Readability means to avoid useless boilerplate text and clutter,
166-
therefore some efforts are spent trying to achieve a certain level of brevity.
167-
But terseness and obscurity are the limits where brevity should stop. Being
168-
able to tell immediately where a class or function comes from, as in the
164+
As mentioned in the :ref:`code_style` section, readability is one of the main
165+
features of Python. Readability means to avoid useless boilerplate text and
166+
clutter, therefore some efforts are spent trying to achieve a certain level of
167+
brevity. But terseness and obscurity are the limits where brevity should stop.
168+
Being able to tell immediately where a class or function comes from, as in the
169169
``modu.func`` idiom, greatly improves code readability and understandability in
170170
all but the simplest single file projects.
171171

@@ -183,13 +183,13 @@ gather all package-wide definitions.
183183

184184
A file :file:`modu.py` in the directory :file:`pack/` is imported with the statement ``import
185185
pack.modu``. This statement will look for an :file:`__init__.py` file in :file:`pack`, execute
186-
all of its top-level statements. Then it will look for a file :file:`pack/modu.py` and
186+
all of its top-level statements. Then it will look for a file named :file:`pack/modu.py` and
187187
execute all of its top-level statements. After these operations, any variable,
188188
function, or class defined in :file:`modu.py` is available in the pack.modu namespace.
189189

190190
A commonly seen issue is to add too much code to :file:`__init__.py`
191191
files. When the project complexity grows, there may be sub-packages and
192-
sub-sub-packages in a deep directory structure, and then, importing a single item
192+
sub-sub-packages in a deep directory structure. In this case, importing a single item
193193
from a sub-sub-package will require executing all :file:`__init__.py` files met while
194194
traversing the tree.
195195

@@ -207,7 +207,7 @@ Python is sometimes described as an object-oriented programming language. This
207207
can be somewhat misleading and needs to be clarified.
208208

209209
In Python, everything is an object, and can be handled as such. This is what is
210-
meant when we say that, for example, functions are first-class objects.
210+
meant when we say, for example, that functions are first-class objects.
211211
Functions, classes, strings, and even types are objects in Python: like any
212212
objects, they have a type, they can be passed as function arguments, they may
213213
have methods and properties. In this understanding, Python is an
@@ -284,7 +284,7 @@ The Python language provides a simple yet powerful syntax called 'decorators'.
284284
A decorator is a function or a class that wraps (or decorates) a function
285285
or a method. The 'decorated' function or method will replace the original
286286
'undecorated' function or method. Because functions are first-class objects
287-
in Python, it can be done 'manually', but using the @decorator syntax is
287+
in Python, this can be done 'manually', but using the @decorator syntax is
288288
clearer and thus preferred.
289289

290290
.. code-block:: python

docs/writing/style.rst

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ calls to ``send('Hello', 'World')`` and ``point(1, 2)``.
101101

102102
2. **Keyword arguments** are not mandatory and have default values. They are often
103103
used for optional parameters sent to the function. When a function has more than
104-
two or three positional parameters, its signature will be more difficult to remember
104+
two or three positional parameters, its signature is more difficult to remember
105105
and using keyword argument with default values is helpful. For instance, a more
106106
complete ``send`` function could be defined as ``send(message, to, cc=None, bcc=None)``.
107107
Here ``cc`` and ``bcc`` are optional, and evaluate to ``None`` when they are not
@@ -176,15 +176,15 @@ possible to do each of the following:
176176

177177
However, all these options have many drawbacks and it is always better to use
178178
the most straightforward way to achieve your goal. The main drawback is that
179-
readability suffers deeply from them. Many code analysis tools, such as pylint
180-
or pyflakes, will be unable to parse this "magic" code.
179+
readability suffers greatly when using these constructs. Many code analysis
180+
tools, such as pylint or pyflakes, will be unable to parse this "magic" code.
181181

182182
We consider that a Python developer should know about these nearly infinite
183-
possibilities, because it grows the confidence that no hard-wall will be on the
184-
way. However, knowing how to use them and particularly when **not** to use
185-
them is the most important.
183+
possibilities, because it instills confidence that no impassable problem will
184+
be on the way. However, knowing how and particularly when **not** to use
185+
them is very important.
186186

187-
Like a Kungfu master, a Pythonista knows how to kill with a single finger, and
187+
Like a kung fu master, a Pythonista knows how to kill with a single finger, and
188188
never to actually do it.
189189

190190
We are all consenting adults
@@ -195,10 +195,10 @@ dangerous. A good example is that any client code can override an object's
195195
properties and methods: there is no "private" keyword in Python. This
196196
philosophy, very different from highly defensive languages like Java, which
197197
give a lot of mechanisms to prevent any misuse, is expressed by the saying: "We
198-
are consenting adults".
198+
are all consenting adults".
199199

200200
This doesn't mean that, for example, no properties are considered private, and
201-
that no proper encapsulation is possible in Python. But, instead of relying on
201+
that no proper encapsulation is possible in Python. Rather, instead of relying on
202202
concrete walls erected by the developers between their code and other's, the
203203
Python community prefers to rely on a set of conventions indicating that these
204204
elements should not be accessed directly.
@@ -210,8 +210,8 @@ the code is modified is the responsibility of the client code.
210210

211211
Using this convention generously is encouraged: any method or property that is
212212
not intended to be used by client code should be prefixed with an underscore.
213-
This will guarantee a better separation of duties and easier modifications of
214-
existing code, and it will always be possible to publicize a private property,
213+
This will guarantee a better separation of duties and easier modification of
214+
existing code; it will always be possible to publicize a private property,
215215
while privatising a public property might be a much harder operation.
216216

217217
Returning values
@@ -235,7 +235,7 @@ statement can assume the condition is met to further compute the function's main
235235
Having multiple such return statements is often necessary.
236236

237237
However, when a function has multiple main exit points for its normal course, it becomes
238-
difficult to debug the returned result, and it may be preferable to keep a single exit
238+
difficult to debug the returned result, so it may be preferable to keep a single exit
239239
point. This will also help factoring out some code paths, and the multiple exit points
240240
are a probable indication that such a refactoring is needed.
241241

@@ -281,7 +281,7 @@ a tuple of two elements for each item in list:
281281
for index, item in enumerate(some_list):
282282
# do something with index and item
283283
284-
You can use this to swap variables, as well:
284+
You can use this to swap variables as well:
285285

286286
.. code-block:: python
287287
@@ -360,9 +360,13 @@ Take the following code for example:
360360
def lookup_list(l):
361361
return 's' in l
362362
363-
Even though both functions look identical, because *lookup_dict* is utilizing the fact that dictionaries in Python are hashtables, the lookup performance between the two is very different.
364-
Python will have to go through each item in the list to find a matching case, which is time consuming. By analysing the hash of the dictionary, finding keys in the dict can be done very quickly.
365-
For more information see this `StackOverflow <http://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table>`_ page.
363+
Even though both functions look identical, because *lookup_dict* is utilizing
364+
the fact that dictionaries in Python are hashtables, the lookup performance
365+
between the two is very different. Python will have to go through each item
366+
in the list to find a matching case, which is time consuming. By analysing
367+
the hash of the dictionary, finding keys in the dict can be done very quickly.
368+
For more information see this `StackOverflow <http://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table>`_
369+
page.
366370

367371
Zen of Python
368372
-------------
@@ -406,7 +410,7 @@ PEP 8
406410

407411
Conforming your Python code to PEP 8 is generally a good idea and helps make
408412
code more consistent when working on projects with other developers. There
409-
exists a command-line program, `pep8 <https://github.com/jcrocholl/pep8>`_,
413+
is a command-line program, `pep8 <https://github.com/jcrocholl/pep8>`_,
410414
that can check your code for conformance. Install it by running the following
411415
command in your Terminal:
412416

@@ -584,19 +588,19 @@ files for you.
584588
print line
585589
586590
The ``with`` statement is better because it will ensure you always close the
587-
file, even if an exception is raised.
591+
file, even if an exception is raised inside the ``with`` block.
588592

589593
Line Continuations
590594
~~~~~~~~~~~~~~~~~~
591595

592596
When a logical line of code is longer than the accepted limit, you need to
593-
split it over multiple physical lines. Python interpreter will join consecutive
597+
split it over multiple physical lines. The Python interpreter will join consecutive
594598
lines if the last character of the line is a backslash. This is helpful
595-
sometimes but is preferably avoided, because of its fragility: a white space
599+
in some cases, but should usually be avoided because of its fragility: a white space
596600
added to the end of the line, after the backslash, will break the code and may
597601
have unexpected results.
598602

599-
A preferred solution is to use parentheses around your elements. Left with an
603+
A better solution is to use parentheses around your elements. Left with an
600604
unclosed parenthesis on an end-of-line the Python interpreter will join the
601605
next line until the parentheses are closed. The same behavior holds for curly
602606
and square braces.

docs/writing/tests.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Some general rules of testing:
4444

4545
- The first step when you are debugging your code is to write a new test
4646
pinpointing the bug. While it is not always possible to do, those bug
47-
catching test are among the most valuable pieces of code in your project.
47+
catching tests are among the most valuable pieces of code in your project.
4848

4949
- Use long and descriptive names for testing functions. The style guide here
5050
is slightly different than that of running code, where short names are
@@ -66,8 +66,8 @@ Some general rules of testing:
6666
testing code is often the best they can do. They will or should discover the
6767
hot spots, where most difficulties arise, and the corner cases. If they have
6868
to add some functionality, the first step should be to add a test and, by this
69-
mean, ensure the new functionality is not already a working path that has not
70-
been plugged in the interface.
69+
means, ensure the new functionality is not already a working path that has not
70+
been plugged into the interface.
7171

7272
The Basics
7373
::::::::::

0 commit comments

Comments
 (0)