Skip to content

Commit 5e0b5ff

Browse files
committed
Proofread articles.
1 parent 73c29a1 commit 5e0b5ff

17 files changed

+24
-24
lines changed
12 KB
Binary file not shown.

docs/correctness/access_to_a_protected_member.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Solutions
3737
Use ``property`` to access the member
3838
.....................................
3939

40-
For new-style classes (classes that derive from ``object``, e.g. ``class Rectangle(object):``) the Pythonic way to access members is to use the built-in Python function ``property()``.
40+
For new-style classes (classes that derive from ``object``, e.g. ``class Rectangle(object)``) the Pythonic way to access members is to use the built-in Python function ``property()``.
4141

4242
.. code:: python
4343
@@ -66,7 +66,7 @@ For new-style classes (classes that derive from ``object``, e.g. ``class Rectang
6666
Add protected member to ``__all__``
6767
...................................
6868

69-
If the author of the class decides that it is accessible to directly access the protected member, he can add the protected member to the module's ``__all__`` class to indicate this. The code will execute either way, but this at least explicitly documents that it is acceptable to directly access the member.
69+
If the author of the class decides that it is acceptable to directly access the protected member, he can add the protected member to the module's ``__all__`` class to indicate this. The code will execute either way, but this at least explicitly documents that it is acceptable to directly access the member.
7070

7171
.. code:: python
7272

docs/correctness/an_attribute_hides_this_method.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ An attribute hides this method
44
Summary
55
-------
66

7-
An attribute and a method of a class share the same name. Give the two objects unique names or else Python will raise a ``TypeError: object is not callable`` error at runtime. Python raises the error because the name is associated to the attribute, so when you insert parentheses after the name, Python actually tries to call the attribute although you were trying to call the function.
7+
An attribute and a method of a class share the same name. Give unique names to the two objects or else Python will raise a ``TypeError: object is not callable`` error at runtime. Python raises the error because the name is associated to the attribute, so when you insert parentheses after the name, Python actually tries to call the attribute (although you were trying to call the function).
88

99
Description
1010
-----------
1111

12-
When an attribute and a method have the same name, Python gives the attribute precedence. Because two objects cannot have the same name while residing in the same namespace, the method will effectively be hidden. If you try to call the method, Python will actually attempt to call the attribute, and a ``TypeError`` runtime error will occur and the module will not successfully execute. Therefore when you encounter this error you must modify the attribute and method to have unique names.
12+
When an attribute and a method have the same name, Python gives the attribute precedence. Because two objects cannot have the same name while residing in the same namespace, the method will effectively be hidden. If you try to call the method, Python will actually attempt to call the attribute, a ``TypeError`` runtime error will occur, and the module will not successfully execute. Therefore when you encounter this error you must modify the attribute and method to have unique names.
1313

1414
This error often occurs when somebody implements a getter/setter method for accessing an instance attribute. Python style conventions actually prefers that you remove the getter/setter method and just access the attribute directly.
1515

docs/correctness/arguments_number_differs_from_method.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ Arguments number differs from method
44
Summary
55
-------
66

7-
A child class has implemented an abstract method with a different number of arguments than what is defined in the parent class' method signature. Treat this as a warning. The child class' implementation should match the argument signature defined in the the parent class.
7+
A child class has implemented an abstract method with a different number of arguments than what is defined in the method signature of the parent class. Treat this error as a warning. The child class' implementation should match the argument signature defined in the parent class.
88

99
Description
1010
-----------
1111

12-
If the child class' implementation of the parent class' abstract method contains more arguments than the method signature in the parent class, Python will be able to execute the method. If the child class' implementation has less arguments than what is defined in the parent class' abstract method signature, then Python will not be able to execute the method. Either way, this defeats the purpose of abstract methods. Abstract methods are contracts passed down to inherited classes which signify that the parent class expects its children to implement a method that matches a particular argument signature. When the child class does not match the signature defined in the parent class, it is not fulfilling its part of the inheritance contract.
12+
There are two outcomes that can occur when the number of arguments in a child class implementation does not match the abstract method signature in the parent class. If the child class contains more arguments than the parent class, then Python can execute the code. If the number of arguments in the child class is less than the parent class abstract method signature, then Python cannot execute the code. Either way, this defeats the purpose of abstract methods. Abstract methods are contracts passed down to inherited classes from parent classes. The children are supposed to implement a method that matches the argument signature defined by the parent. When the child class does not match the signature defined in the parent class, it is not fulfilling its part of the inheritance contract.
1313

1414
Examples
1515
----------
1616

17-
Child class method contains more arguments than parent class' method signature
17+
Child class method contains more arguments than parent class method signature
1818
..............................................................................
1919

2020
In the module below ``Dog`` is a child class of ``Animal``. ``Dog`` is supposed to implement a class called ``print_class_information`` that takes no arguments. However, ``Dog``'s implementation accepts one argument, ``biological_family``.

docs/correctness/assigning_to_function_call_which_only_returns_none.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Note that the ``Assigning to function call which only returns once`` is NOT rais
4040
4141
def hello():
4242
print "hello"
43-
return
43+
return # although this is equivalent to Return None, error is not raised (but it should be)
4444
4545
v = hello()
4646
print v # WARNING: always returns None, but error not raised!

docs/correctness/bad_first_argument_given_to_super.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The first argument to ``super()`` should be the class name of the child class th
99
Description
1010
-----------
1111

12-
``super()`` enables you to access the methods and members of a parent class without referring to the parent class by name. For a single inheritance situation the first argument to ``super()`` should be the name of the current child class calling ``super()``, and the second argument should be ``self``, that is, a reference to the current object calling ``super()``.
12+
``super()`` enables you to access the methods and members of a parent class without referring to the parent class by name. For a single inheritance situation the first argument to ``super()`` should be the name of the current child class calling ``super()``, and the second argument should be ``self`` (that is, a reference to the current object calling ``super()``).
1313

1414
Examples
1515
----------

docs/correctness/class_has_no_init_method.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The ``Car`` class triggers the ``class has no __init__ method`` warning because
2323

2424
.. code:: python
2525
26-
class Car:
26+
class Car: # class defines no __init__ method
2727
def print_class_name(self):
2828
print "Car"
2929

docs/correctness/class_has_no_member.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ When a module attempts to use a member of a class which is not defined in that c
1414
Examples
1515
----------
1616

17-
Description of error
18-
....................
17+
Reference to unimplemented member
18+
.................................
1919

2020
The module below attempts to call a function from the ``Rectangle`` class called ``area``. This raises the ``class has no member`` error because the ``area`` function in undefined in the ``Rectangle`` class.
2121

docs/correctness/do_not_assign_a_lambda_expression.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Do not assign a ``lambda`` expression, use a ``def``
44
Summary
55
-------
66

7-
Assigning a name to a ``lambda`` essentially duplicates the functionality of ``def``, in which case you should just use a ``def`` in order to avoid confusion and increase clarity.
7+
Assigning a name to a ``lambda`` essentially duplicates the functionality of ``def`` (a function definition), in which case you should just use a ``def`` in order to avoid confusion and increase clarity.
88

99
Description
1010
-----------

docs/correctness/duplicate_argument_name_in_function_definition.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Two or more parameters in a function definition have the exact same name. Give e
99
Description
1010
-----------
1111

12-
When two or more parameters have the same name in a function definition, Python cannot resolve which parameter is being referenced whenever that name is used. The only solution to this situation is to give each name a unique meaning. This is a good programming practice in general; names should not be overloaded with multiple meanings.
12+
When two or more parameters have the same name in a function definition, Python cannot resolve which parameter is being referenced. The only solution to this situation is to give each parameter a unique name. This is a good programming practice in general; names should not be overloaded with multiple meanings.
1313

1414
Examples
1515
----------

0 commit comments

Comments
 (0)