@@ -42,7 +42,7 @@ add new capabilities one by one.
42
42
Simple example: A descriptor that returns a constant
43
43
----------------------------------------------------
44
44
45
- The :class: ` Ten ` class is a descriptor whose :meth: `__get__ ` method always
45
+ The `` Ten ` ` class is a descriptor whose :meth: `__get__ ` method always
46
46
returns the constant ``10 ``:
47
47
48
48
.. testcode ::
@@ -215,8 +215,8 @@ Customized names
215
215
When a class uses descriptors, it can inform each descriptor about which
216
216
variable name was used.
217
217
218
- In this example, the :class: ` Person ` class has two descriptor instances,
219
- *name * and *age *. When the :class: ` Person ` class is defined, it makes a
218
+ In this example, the `` Person ` ` class has two descriptor instances,
219
+ *name * and *age *. When the `` Person ` ` class is defined, it makes a
220
220
callback to :meth: `__set_name__ ` in *LoggedAccess * so that the field names can
221
221
be recorded, giving each descriptor its own *public_name * and *private_name *:
222
222
@@ -253,7 +253,7 @@ be recorded, giving each descriptor its own *public_name* and *private_name*:
253
253
def birthday(self):
254
254
self.age += 1
255
255
256
- An interactive session shows that the :class: ` Person ` class has called
256
+ An interactive session shows that the `` Person ` ` class has called
257
257
:meth: `__set_name__ ` so that the field names would be recorded. Here
258
258
we call :func: `vars ` to look up the descriptor without triggering it:
259
259
@@ -337,7 +337,7 @@ any data, it verifies that the new value meets various type and range
337
337
restrictions. If those restrictions aren't met, it raises an exception to
338
338
prevent data corruption at its source.
339
339
340
- This :class: ` Validator ` class is both an :term: `abstract base class ` and a
340
+ This `` Validator ` ` class is both an :term: `abstract base class ` and a
341
341
managed attribute descriptor:
342
342
343
343
.. testcode ::
@@ -360,22 +360,22 @@ managed attribute descriptor:
360
360
def validate(self, value):
361
361
pass
362
362
363
- Custom validators need to inherit from :class: ` Validator ` and must supply a
364
- :meth: ` validate ` method to test various restrictions as needed.
363
+ Custom validators need to inherit from `` Validator ` ` and must supply a
364
+ `` validate ` ` method to test various restrictions as needed.
365
365
366
366
367
367
Custom validators
368
368
-----------------
369
369
370
370
Here are three practical data validation utilities:
371
371
372
- 1) :class: ` OneOf ` verifies that a value is one of a restricted set of options.
372
+ 1) `` OneOf ` ` verifies that a value is one of a restricted set of options.
373
373
374
- 2) :class: ` Number ` verifies that a value is either an :class: `int ` or
374
+ 2) `` Number ` ` verifies that a value is either an :class: `int ` or
375
375
:class: `float `. Optionally, it verifies that a value is between a given
376
376
minimum or maximum.
377
377
378
- 3) :class: ` String ` verifies that a value is a :class: `str `. Optionally, it
378
+ 3) `` String ` ` verifies that a value is a :class: `str `. Optionally, it
379
379
validates a given minimum or maximum length. It can validate a
380
380
user-defined `predicate
381
381
<https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)> `_ as well.
@@ -873,7 +873,7 @@ care of lookups or updates:
873
873
conn.execute(self.store, [value, obj.key])
874
874
conn.commit()
875
875
876
- We can use the :class: ` Field ` class to define `models
876
+ We can use the `` Field ` ` class to define `models
877
877
<https://en.wikipedia.org/wiki/Database_model> `_ that describe the schema for
878
878
each table in a database:
879
879
@@ -1140,7 +1140,7 @@ to wrap access to the value attribute in a property data descriptor:
1140
1140
self.recalc()
1141
1141
return self._value
1142
1142
1143
- Either the built-in :func: `property ` or our :func: ` Property ` equivalent would
1143
+ Either the built-in :func: `property ` or our `` Property ` ` equivalent would
1144
1144
work in this example.
1145
1145
1146
1146
@@ -1722,7 +1722,7 @@ Python:
1722
1722
)
1723
1723
super().__delattr__(name)
1724
1724
1725
- To use the simulation in a real class, just inherit from :class: ` Object ` and
1725
+ To use the simulation in a real class, just inherit from `` Object ` ` and
1726
1726
set the :term: `metaclass ` to :class: `Type `:
1727
1727
1728
1728
.. testcode ::
0 commit comments