Skip to content

Commit b2ffd49

Browse files
[3.13] Minor edits to the descriptor guide (GH-123928) (#124079)
Minor edits to the descriptor guide (GH-123928) (cherry picked from commit cd06f5e) Co-authored-by: Raymond Hettinger <[email protected]>
1 parent 4cd4bf1 commit b2ffd49

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: Doc/howto/descriptor.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ Here are three practical data validation utilities:
389389
390390
def validate(self, value):
391391
if value not in self.options:
392-
raise ValueError(f'Expected {value!r} to be one of {self.options!r}')
392+
raise ValueError(
393+
f'Expected {value!r} to be one of {self.options!r}'
394+
)
393395

394396
class Number(Validator):
395397

@@ -469,6 +471,7 @@ The descriptors prevent invalid instances from being created:
469471
Traceback (most recent call last):
470472
...
471473
ValueError: Expected -5 to be at least 0
474+
472475
>>> Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number
473476
Traceback (most recent call last):
474477
...
@@ -1004,7 +1007,6 @@ here is a pure Python equivalent that implements most of the core functionality:
10041007
if doc is None and fget is not None:
10051008
doc = fget.__doc__
10061009
self.__doc__ = doc
1007-
self.__name__ = ''
10081010

10091011
def __set_name__(self, owner, name):
10101012
self.__name__ = name
@@ -1303,8 +1305,8 @@ mean, median, and other descriptive statistics that depend on the data. However,
13031305
there may be useful functions which are conceptually related but do not depend
13041306
on the data. For instance, ``erf(x)`` is handy conversion routine that comes up
13051307
in statistical work but does not directly depend on a particular dataset.
1306-
It can be called either from an object or the class: ``s.erf(1.5) --> .9332`` or
1307-
``Sample.erf(1.5) --> .9332``.
1308+
It can be called either from an object or the class: ``s.erf(1.5) --> 0.9332``
1309+
or ``Sample.erf(1.5) --> 0.9332``.
13081310

13091311
Since static methods return the underlying function with no changes, the
13101312
example calls are unexciting:

0 commit comments

Comments
 (0)