You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more useful help for special name in help() #137574
Now, use help("__name__") and some other special variables' names will still get the help from their class. I think that we can add the useful help on them. For example:
help has an interactive mode, entered with help(), in which one can enter an unquoted word (module, keyword, or topic), symbol (such as .) to get specific help, or “modules”, “keywords”,
“symbols”, or “topics” for a list of those available. It would be plausible to request that special (double-underscored, dunder) names be recognized, with “dunders” or “specials” returning a list of those recognized. In particular, help> name could give a purpose-written entry similar to that proposed above.
I believe that there have been multiple requests that help('whatever') check for special help on whatever before spewing out the 400+ pages of help on str (and without having to enter interactive help). The latter is easily available with help(''). The would, however, be a larger change.
I believe that there have been multiple requests that help('whatever') check for special help on whatever before spewing out the 400+ pages of help on str
It does. Try help("<") or help("int") or help("re").
But I think that it would better to stop falling back to the str class help for every other string. Better to output an error, maybe with a suggestion as for other typos.
But I think that it would better to stop falling back to the str class help for every other string. Better to output an error, maybe with a suggestion as for other typos.
It looks like this already happens in many (but not all) cases, e.g.:
>>> help("foo")
No Python documentation found for 'foo'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
help("__main__") takes me to some useful docs, but help("__name__") tells me about str.
I'd be happy to have a go at this if no one else is working on it yet.
Activity
terryjreedy commentedon Aug 9, 2025
https://discuss.python.org/t/function-help-to-some-special-words/101625 I there suggested the alternative:
I believe that there have been multiple requests that help('whatever') check for special help on whatever before spewing out the 400+ pages of help on
str(and without having to enter interactive help). The latter is easily available with help(''). The would, however, be a larger change.StanFromIreland commentedon Aug 9, 2025
This old deferred PEP may be of interest: PEP 233
serhiy-storchaka commentedon Aug 9, 2025
It does. Try
help("<")orhelp("int")orhelp("re").But I think that it would better to stop falling back to the
strclass help for every other string. Better to output an error, maybe with a suggestion as for other typos.adqm commentedon Aug 11, 2025
It looks like this already happens in many (but not all) cases, e.g.:
help("__main__")takes me to some useful docs, buthelp("__name__")tells me aboutstr.I'd be happy to have a go at this if no one else is working on it yet.