diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-03-25 00:07:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-25 00:07:47 (GMT) |
commit | 62be33870e2f8517314bf9c7275548e799296f7e (patch) | |
tree | e9672e209278b126d76299f0fc563e82d5087dae /Lib/pydoc.py | |
parent | 113d735e2091427f9623097d2a222dd99b16b568 (diff) | |
download | cpython-62be33870e2f8517314bf9c7275548e799296f7e.zip cpython-62be33870e2f8517314bf9c7275548e799296f7e.tar.gz cpython-62be33870e2f8517314bf9c7275548e799296f7e.tar.bz2 |
bpo-36401: Have help() show readonly properties separately (GH-12517)
Diffstat (limited to 'Lib/pydoc.py')
-rw-r--r-- | Lib/pydoc.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index daa7205..2f570e4 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -203,6 +203,8 @@ def classify_class_attrs(object): for (name, kind, cls, value) in inspect.classify_class_attrs(object): if inspect.isdatadescriptor(value): kind = 'data descriptor' + if isinstance(value, property) and value.fset is None: + kind = 'readonly property' results.append((name, kind, cls, value)) return results @@ -884,6 +886,8 @@ class HTMLDoc(Doc): lambda t: t[1] == 'class method') attrs = spill('Static methods %s' % tag, attrs, lambda t: t[1] == 'static method') + attrs = spilldescriptors("Readonly properties %s:\n" % tag, attrs, + lambda t: t[1] == 'readonly property') attrs = spilldescriptors('Data descriptors %s' % tag, attrs, lambda t: t[1] == 'data descriptor') attrs = spilldata('Data and other attributes %s' % tag, attrs, @@ -1341,6 +1345,8 @@ location listed above. lambda t: t[1] == 'class method') attrs = spill("Static methods %s:\n" % tag, attrs, lambda t: t[1] == 'static method') + attrs = spilldescriptors("Readonly properties %s:\n" % tag, attrs, + lambda t: t[1] == 'readonly property') attrs = spilldescriptors("Data descriptors %s:\n" % tag, attrs, lambda t: t[1] == 'data descriptor') attrs = spilldata("Data and other attributes %s:\n" % tag, attrs, |