Skip to content

Commit 7e0e9bf

Browse files
committed
Use more descriptive class name for readability and fix indent
1 parent 12f8a3a commit 7e0e9bf

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

Doc/library/inspect.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -428,33 +428,32 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
428428

429429
For example, given this class::
430430

431-
>>> class Class:
432-
... def say_hello(self):
433-
... print('hello!')
434-
>>>
431+
>>> class Greeter:
432+
... def say_hello(self):
433+
... print('hello!')
435434

436435
A bound method (also known as an *instance method*) is created when
437-
accessing ``say_hello`` (a :term:`function` defined in a
438-
class namespace) through an instance of the class::
436+
accessing ``say_hello`` (a :term:`function` defined in the
437+
``Greeter`` namespace) through an instance of the ``Greeter`` class::
439438

440-
>>> instance = Class()
439+
>>> instance = Greeter()
441440

442441
>>> instance.say_hello
443-
<bound method Class.say_hello of <__main__.Class object ...>>
442+
<bound method Greeter.say_hello of <__main__.Greeter object ...>>
444443
>>> ismethod(instance.say_hello)
445444
True
446445
>>> isfunction(instance.say_hello)
447446
False
448447

449-
Accessing ``say_hello`` through the class will return the function itself.
450-
For this function, :func:`ismethod` will return ``False``,
451-
but :func:`isfunction` will return ``True``::
448+
Accessing ``say_hello`` through the ``Greeter`` class will return the
449+
function itself. For this function, :func:`ismethod` will return
450+
``False``, but :func:`isfunction` will return ``True``::
452451

453-
>>> Class.say_hello
454-
<function Class.say_hello at 0x7f7503854a90>
455-
>>> ismethod(Class.say_hello)
452+
>>> Greeter.say_hello
453+
<function Greeter.say_hello at 0x7f7503854a90>
454+
>>> ismethod(Greeter.say_hello)
456455
False
457-
>>> isfunction(Class.say_hello)
456+
>>> isfunction(Greeter.say_hello)
458457
True
459458

460459
See :ref:`typesmethods` for details.

0 commit comments

Comments
 (0)