@@ -68,6 +68,7 @@ class or function within a module or module in a package. If the
68
68
import re
69
69
import sys
70
70
import sysconfig
71
+ import textwrap
71
72
import time
72
73
import tokenize
73
74
import urllib .parse
@@ -1809,6 +1810,37 @@ def writedocs(dir, pkgpath='', done=None):
1809
1810
writedoc (modname )
1810
1811
return
1811
1812
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
+
1812
1844
class Helper :
1813
1845
1814
1846
# These dictionaries map a topic name to either an alias, or a tuple
@@ -2075,23 +2107,7 @@ def help(self, request, is_cli=False):
2075
2107
self .output .write ('\n ' )
2076
2108
2077
2109
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 ())
2095
2111
2096
2112
def list (self , items , columns = 4 , width = 80 ):
2097
2113
items = list (sorted (items ))
0 commit comments