@@ -2088,7 +2088,9 @@ def getline(self, prompt):
20882088 def help (self , request , is_cli = False , is_interactive = False ):
20892089 if isinstance (request , str ):
20902090 request = request .strip ()
2091- if request == 'keywords' : self .listkeywords ()
2091+ if request == 'help' :
2092+ self .helphelp (is_interactive = is_interactive )
2093+ elif request == 'keywords' : self .listkeywords ()
20922094 elif request == 'symbols' : self .listsymbols ()
20932095 elif request == 'topics' : self .listtopics ()
20942096 elif request == 'modules' : self .listmodules ()
@@ -2103,10 +2105,35 @@ def help(self, request, is_cli=False, is_interactive=False):
21032105 elif request :
21042106 doc (request , 'Help on %s:' , output = self ._output , is_cli = is_cli , is_interactive = is_interactive )
21052107 else : doc (str , 'Help on %s:' , output = self ._output , is_cli = is_cli )
2106- elif isinstance (request , Helper ): self ()
2108+ elif isinstance (request , (Helper , type (builtins .help ))):
2109+ self .helphelp (is_interactive = is_interactive )
21072110 else : doc (request , 'Help on %s:' , output = self ._output , is_cli = is_cli )
21082111 self .output .write ('\n ' )
21092112
2113+ def helphelp (self , is_interactive = False ):
2114+ if is_interactive :
2115+ self .output .write (_introdoc ())
2116+ else :
2117+ pager (textwrap .dedent ("""\
2118+ help - Interactive Help
2119+ =======================
2120+ The built-in help function implements an interactive help utility. You
2121+ can make use of it in a few different ways:
2122+
2123+ * Calling help() with no arguments starts an interactive help session.
2124+
2125+ * Calling help(x) will have one of two behaviors depending on the type
2126+ of the argument:
2127+
2128+ * If x is a string, help(x) provides information about the given
2129+ topic. For example, help("class") will provide information about
2130+ the "class" keyword, and help("math.sqrt") will provide
2131+ information about the "math.sqrt" function.
2132+
2133+ * If x is not a string, help(x) prints information about x's type.
2134+ For example, help(42) will provide information about the int type.
2135+ """ ))
2136+
21102137 def intro (self ):
21112138 self .output .write (_introdoc ())
21122139
0 commit comments