@@ -68,6 +68,7 @@ class or function within a module or module in a package. If the
6868import re
6969import sys
7070import sysconfig
71+ import textwrap
7172import time
7273import tokenize
7374import urllib .parse
@@ -1809,6 +1810,37 @@ def writedocs(dir, pkgpath='', done=None):
18091810 writedoc (modname )
18101811 return
18111812
1813+
1814+ def _introdoc ():
1815+ import textwrap
1816+ ver = '%d.%d' % sys .version_info [:2 ]
1817+ if os .environ .get ('PYTHON_BASIC_REPL' ):
1818+ pyrepl_keys = ''
1819+ else :
1820+ # Additional help for keyboard shortcuts if enhanced REPL is used.
1821+ pyrepl_keys = '''
1822+ You can use the following keyboard shortcuts at the main interpreter prompt.
1823+ F1: enter interactive help, F2: enter history browsing mode, F3: enter paste
1824+ mode (press again to exit).
1825+ '''
1826+ return textwrap .dedent (f'''\
1827+ Welcome to Python { ver } 's help utility! If this is your first time using
1828+ Python, you should definitely check out the tutorial at
1829+ https://docs.python.org/{ ver } /tutorial/.
1830+
1831+ Enter the name of any module, keyword, or topic to get help on writing
1832+ Python programs and using Python modules. To get a list of available
1833+ modules, keywords, symbols, or topics, enter "modules", "keywords",
1834+ "symbols", or "topics".
1835+ { pyrepl_keys }
1836+ Each module also comes with a one-line summary of what it does; to list
1837+ the modules whose name or summary contain a given string such as "spam",
1838+ enter "modules spam".
1839+
1840+ To quit this help utility and return to the interpreter,
1841+ enter "q", "quit" or "exit".
1842+ ''' )
1843+
18121844class Helper :
18131845
18141846 # These dictionaries map a topic name to either an alias, or a tuple
@@ -2075,23 +2107,7 @@ def help(self, request, is_cli=False):
20752107 self .output .write ('\n ' )
20762108
20772109 def intro (self ):
2078- self .output .write ('''\
2079- Welcome to Python {0}'s help utility! If this is your first time using
2080- Python, you should definitely check out the tutorial at
2081- https://docs.python.org/{0}/tutorial/.
2082-
2083- Enter the name of any module, keyword, or topic to get help on writing
2084- Python programs and using Python modules. To get a list of available
2085- modules, keywords, symbols, or topics, enter "modules", "keywords",
2086- "symbols", or "topics".
2087-
2088- Each module also comes with a one-line summary of what it does; to list
2089- the modules whose name or summary contain a given string such as "spam",
2090- enter "modules spam".
2091-
2092- To quit this help utility and return to the interpreter,
2093- enter "q", "quit" or "exit".
2094- ''' .format ('%d.%d' % sys .version_info [:2 ]))
2110+ self .output .write (_introdoc ())
20952111
20962112 def list (self , items , columns = 4 , width = 80 ):
20972113 items = list (sorted (items ))
0 commit comments