nr: #1 dodano: 2016-12-25 17:12
There isn't much of a twist. The twist is that
pydoc is lazily imported and the object has a
__repr__ method that provides direct feedback on how to use the object:
'Type help() for interactive help, or help(object) for help about object.'
__repr__ method is called whenever you echo the
help object in the interactive prompt:
Type help() for interactive help, or help(object) for help about object.
Python 3.4 got rid of the 'twist' description altogether, replacing it with something a little more descriptive; see issue 9364. Quoting the bug reporter:
"(with a twist)" thanks a lot. I think the comment should be either removed or explained. A reference manual should explain, not tease.
followed by a developer's response:
Agreed. I think the “twist” is that the import is lazy and that help has a useful repr (wow, talk about a twist!). Those details need not be alluded to, just remove the comment (“wrapper” is IMO enough to raise curiosity, the source is here to find what’s the wrapping).
The docstring now reads:
"""Define the builtin 'help'.
This is a wrapper around pydoc.help that provides a helpful message
when 'help' is typed at the Python interactive prompt.
Calling help() at the Python prompt starts an interactive help session.
Calling help(thing) prints help for the python object 'thing'.