Skip to content

Commit c197cab

Browse files
committed
✏️ Fix Typos and reST syntax
1 parent 9d8d46a commit c197cab

File tree

5 files changed

+66
-65
lines changed

5 files changed

+66
-65
lines changed

docs/appendix/checks.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ Checks
354354
(``-``)?
355355

356356
.. code-block:: pycon
357+
357358
>>> from string import punctuation, whitespace
358359
>>> chars = punctuation + whitespace
359360
>>> subs = str.maketrans(chars, len(chars) * "-")
@@ -813,7 +814,7 @@ Checks
813814
:doc:`/oop/classes`
814815
-------------------
815816

816-
* Writes a :class:`Triangle` class that can also calculate the area.
817+
* Write a :class:`Triangle` class that can also calculate the area.
817818

818819
.. code-block:: python
819820
@@ -828,7 +829,7 @@ Checks
828829
:doc:`/oop/methods`
829830
-------------------
830831

831-
* Writes a class method that is similar to :func:`circumferences`, but returns
832+
* Write a class method that is similar to :func:`circumferences`, but returns
832833
the total area of all circles.
833834

834835
.. code-block:: python

docs/oop/classes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ Line 6
8484
Checks
8585
------
8686

87-
* Writes a :class:`Triangle` class that can also calculate the area.
87+
* Write a :class:`Triangle` class that can also calculate the area.

docs/oop/inheritance.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
RClasses and inheritance
2-
========================
1+
Classes and inheritance
2+
=======================
33

44
Inheritance in Python is simpler and more flexible than inheritance in compiled
55
languages such as Java and C++ because the dynamic nature of Python does not

docs/oop/methods.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,5 @@ Line 27
163163
Checks
164164
------
165165

166-
* Writes a class method that is similar to :func:`circumferences`, but returns
166+
* Write a class method that is similar to :func:`circumferences`, but returns
167167
the total area of all circles.

docs/oop/types.rst

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ simply try the following:
99

1010
.. code-block:: pycon
1111
12-
>>> type(3)
13-
<class 'int'>
14-
>>> type("Hello")
15-
<class 'str'>
16-
>>> type(["Hello", "Pythonistas"])
17-
<class 'list'>
12+
>>> type(3)
13+
<class 'int'>
14+
>>> type("Hello")
15+
<class 'str'>
16+
>>> type(["Hello", "Pythonistas"])
17+
<class 'list'>
1818
1919
In these examples you can see the built-in :class:`type` function in Python. It
2020
can be applied to any Python object and returns the type of the object. In this
@@ -29,10 +29,10 @@ you can compare these Python objects with each other:
2929

3030
.. code-block:: pycon
3131
32-
>>> type("Hello") == type("Pythonistas!")
33-
True
34-
>>> type("Hello") == type("Pythonistas!") == type(["Hello", "Pythonistas"])
35-
False
32+
>>> type("Hello") == type("Pythonistas!")
33+
True
34+
>>> type("Hello") == type("Pythonistas!") == type(["Hello", "Pythonistas"])
35+
False
3636
3737
With this technique you can, among other things, perform a type check in your
3838
function and method definitions. However, the most common question about the
@@ -41,47 +41,47 @@ example with a simple inheritance hierarchy makes this clearer:
4141

4242
#. First, we define two classes with an inheritance hierarchy:
4343

44-
.. code-block:: pycon
44+
.. code-block:: pycon
4545
46-
>>> class Form:
47-
... pass
48-
...
49-
>>> class Square(Form):
50-
... pass
51-
...
52-
>>> class Circle(Form):
53-
... pass
54-
...
46+
>>> class Form:
47+
... pass
48+
...
49+
>>> class Square(Form):
50+
... pass
51+
...
52+
>>> class Circle(Form):
53+
... pass
54+
...
5555
5656
#. Now you can create an instance ``c1`` of the class ``Circle``:
5757

58-
.. code-block:: pycon
58+
.. code-block:: pycon
5959
60-
>>> c1 = Circle()
60+
>>> c1 = Circle()
6161
6262
#. As expected, the ``type`` function on ``c1`` outputs that ``c1`` is an
6363
instance of the class ``Circle`` defined in your current ``__main__``
6464
namespace:
6565

66-
.. code-block:: pycon
66+
.. code-block:: pycon
6767
68-
>>> type(c1)
69-
<class '__main__.Circle'>
68+
>>> type(c1)
69+
<class '__main__.Circle'>
7070
7171
#. You can also get exactly the same information by accessing the ``__class__``
7272
attribute of the instance:
7373

74-
.. code-block:: pycon
74+
.. code-block:: pycon
7575
76-
>>> c1.__class__
77-
<class '__main__.Circle'>
76+
>>> c1.__class__
77+
<class '__main__.Circle'>
7878
7979
#. You can also explicitly check whether the two class objects are identical:
8080

81-
.. code-block:: pycon
81+
.. code-block:: pycon
8282
83-
>>> c1.__class__ == Circle
84-
True
83+
>>> c1.__class__ == Circle
84+
True
8585
8686
#. However, two built-in functions provide a more user-friendly way of obtaining
8787
most of the information normally required:
@@ -92,24 +92,24 @@ example with a simple inheritance hierarchy makes this clearer:
9292
:func:`python3:issubclass`
9393
determines whether one class is the subclass of another.
9494

95-
.. code-block:: pycon
96-
97-
>>> issubclass(Circle, Form)
98-
True
99-
>>> issubclass(Square, Form)
100-
True
101-
>>> isinstance(c1, Form)
102-
True
103-
>>> isinstance(c1, Square)
104-
False
105-
>>> isinstance(c1, Circle)
106-
True
107-
>>> issubclass(c1.__class__, Form)
108-
True
109-
>>> issubclass(c1.__class__, Square)
110-
False
111-
>>> issubclass(c1.__class__, Circle)
112-
True
95+
.. code-block:: pycon
96+
97+
>>> issubclass(Circle, Form)
98+
True
99+
>>> issubclass(Square, Form)
100+
True
101+
>>> isinstance(c1, Form)
102+
True
103+
>>> isinstance(c1, Square)
104+
False
105+
>>> isinstance(c1, Circle)
106+
True
107+
>>> issubclass(c1.__class__, Form)
108+
True
109+
>>> issubclass(c1.__class__, Square)
110+
False
111+
>>> issubclass(c1.__class__, Circle)
112+
True
113113
114114
.. _duck-typing:
115115

@@ -145,16 +145,16 @@ instances in a readable format:
145145

146146
.. code-block:: pycon
147147
148-
>>> class Form:
149-
... def __init__(self, x, y):
150-
... self.x = x
151-
... self.y = y
152-
... def __str__(self):
153-
... return "Position: x={0}, y={1}".format(self.x, self.y)
154-
...
155-
>>> f = Form(2, 3)
156-
>>> print(f)
157-
Position: x=2, y=3
148+
>>> class Form:
149+
... def __init__(self, x, y):
150+
... self.x = x
151+
... self.y = y
152+
... def __str__(self):
153+
... return "Position: x={0}, y={1}".format(self.x, self.y)
154+
...
155+
>>> f = Form(2, 3)
156+
>>> print(f)
157+
Position: x=2, y=3
158158
159159
Even though our special ``__str__`` method attribute was not explicitly called
160160
by our code, it could still be used by Python because Python knows that the

0 commit comments

Comments
 (0)