For some special words, we can use different way to show the help:
For example, help(‘__name__’) will output the text below(or maybe upgrade and be more helpful):
module._name_ : if the module is run as the main module, the value is ‘_main_‘, or the name is the filename of the module. For example:if __name__ == "__main__": ...can control which code don’t run when the module is imported.
cls._name_: the name of the class. It must be str.
Some special variable that have their special way to be defined can use this way to help the users to use them rightly.
To be clear, help() prints help on the class of the object. So the help for any string object is, currently, 436 lines of help on str. (The argument can actually be an expession, which is then evaluated to get the help object.)
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.
Is it ever actually helpful though for help("topic") to be interpreted as help(str)? Would there be any harm in special casing string inputs?
I have memories of being unable to find help for keywords (neither help(class) or help("class") work) or concepts like string formatting (help(str.format) tells you almost nothing). Likewise with the strange things you find in REPL completions like Ellipsis[1].
I’d really like to see help("concept/topic/keyword/operator/etc") become more helpful and less literal than unconditionally feeding an abbreviated API reference for str into a pager.
help(Ellipsis) gives you the boilerplate signature of the ellipsis class which is neither defined in the same namespace nor meaningful to instantiate – no hint as to what it’s for ↩︎
Uhmm, now I am really confused as to how I never found that before. Not only does it work now but I worked on the version of Python I first learnt Python on.