@@ -15,7 +15,7 @@ Inheritance and composition
1515
1616A key feature of abstractions is :term: `composability <composition> `: the
1717ability to make a complex object or operation out of several components. We can
18- compose objects by simply making one object a :term: `attribute ` of another
18+ compose objects by simply making one object an :term: `attribute ` of another
1919object. This combines objects in a *has a * relationship. For example the
2020:class: `~example_code.polynomial.Polynomial ` class introduced in
2121:numref: `Chapter %s <objects >` *has a * :class: `tuple ` of coefficients. Object
@@ -223,7 +223,7 @@ minimal characterisation of a group will suffice.
223223
224224 def __repr__(self):
225225 """Return the canonical string representation of the group."""
226- return f"{type(self).__name__}({repr( self.order) })"
226+ return f"{type(self).__name__}({self.order!r })"
227227
228228:numref: `cyclic_group ` shows an implementation of our minimal conception of
229229cyclic groups. Before considering it in any detail let's try it out to observe
@@ -239,7 +239,7 @@ the concrete effects of the classes:
239239 2_C5
240240
241241 We observe that we are able to create the cyclic group of order 5. Due to the
242- definition of the :meth: `~object.__call__ ` :term: `special method ` at line 35 ,
242+ definition of the :meth: `~object.__call__ ` :term: `special method ` at line 49 ,
243243we are then able to create elements of the group by calling the group object.
244244The group operation then has the expected effect:
245245
@@ -286,7 +286,7 @@ integer between 0 and 5, an exception is raised.
286286:numref: `cyclic_group ` illustrates :term: `composition `: on line 13
287287:class: `~example_code.groups_basic.Element ` is associated with a group object.
288288This is a classic *has a * relationship: an element has a group. We might have
289- attempted to construct this the other way around with classes having elements,
289+ attempted to construct this the other way around with groups having elements,
290290however this would have immediately hit the issue that elements have exactly
291291one group, while a group might have an unlimited number of elements. Object
292292composition is typically most successful when the relationship is uniquely
@@ -356,7 +356,7 @@ follows:
356356
357357 def __repr__(self):
358358 """Return the canonical string representation of the group."""
359- return f"{type(self).__name__}({repr( self.degree) })"
359+ return f"{type(self).__name__}({self.degree!r })"
360360
361361 We won't illustrate the operation of this class, though the reader is welcome to
362362:keyword: `import ` the :mod: `example_code.groups_basic ` module and experiment.
@@ -409,7 +409,7 @@ does.
409409
410410 def __repr__(self):
411411 """Return the canonical string representation of the element."""
412- return f"{type(self).__name__}({repr( self.n) })"
412+ return f"{type(self).__name__}({self.n!r })"
413413
414414
415415 class CyclicGroup(Group):
0 commit comments