https://github.com/python/cpython/commit/68a737691b0fd591de00f4811bb23a5c280fe859
commit: 68a737691b0fd591de00f4811bb23a5c280fe859
branch: main
author: Neil Schemenauer <nas-git...@arctrix.com>
committer: nascheme <nas-git...@arctrix.com>
date: 2025-04-28T14:17:34-07:00
summary:

gh-125142: add REPL help text for keyboard shortcuts (gh-125143)

files:
A Misc/NEWS.d/next/Documentation/2024-10-08-10-44-14.gh-issue-125142.HVlHrs.rst
M Lib/pydoc.py

diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 169194b99cb826..def76d076a2989 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -68,6 +68,7 @@ class or function within a module or module in a package.  If 
the
 import re
 import sys
 import sysconfig
+import textwrap
 import time
 import tokenize
 import urllib.parse
@@ -1809,6 +1810,37 @@ def writedocs(dir, pkgpath='', done=None):
         writedoc(modname)
     return
 
+
+def _introdoc():
+    import textwrap
+    ver = '%d.%d' % sys.version_info[:2]
+    if os.environ.get('PYTHON_BASIC_REPL'):
+        pyrepl_keys = ''
+    else:
+        # Additional help for keyboard shortcuts if enhanced REPL is used.
+        pyrepl_keys = '''
+        You can use the following keyboard shortcuts at the main interpreter 
prompt.
+        F1: enter interactive help, F2: enter history browsing mode, F3: enter 
paste
+        mode (press again to exit).
+        '''
+    return textwrap.dedent(f'''\
+        Welcome to Python {ver}'s help utility! If this is your first time 
using
+        Python, you should definitely check out the tutorial at
+        https://docs.python.org/{ver}/tutorial/.
+
+        Enter the name of any module, keyword, or topic to get help on writing
+        Python programs and using Python modules.  To get a list of available
+        modules, keywords, symbols, or topics, enter "modules", "keywords",
+        "symbols", or "topics".
+        {pyrepl_keys}
+        Each module also comes with a one-line summary of what it does; to list
+        the modules whose name or summary contain a given string such as 
"spam",
+        enter "modules spam".
+
+        To quit this help utility and return to the interpreter,
+        enter "q", "quit" or "exit".
+    ''')
+
 class Helper:
 
     # These dictionaries map a topic name to either an alias, or a tuple
@@ -2075,23 +2107,7 @@ def help(self, request, is_cli=False):
         self.output.write('\n')
 
     def intro(self):
-        self.output.write('''\
-Welcome to Python {0}'s help utility! If this is your first time using
-Python, you should definitely check out the tutorial at
-https://docs.python.org/{0}/tutorial/.
-
-Enter the name of any module, keyword, or topic to get help on writing
-Python programs and using Python modules.  To get a list of available
-modules, keywords, symbols, or topics, enter "modules", "keywords",
-"symbols", or "topics".
-
-Each module also comes with a one-line summary of what it does; to list
-the modules whose name or summary contain a given string such as "spam",
-enter "modules spam".
-
-To quit this help utility and return to the interpreter,
-enter "q", "quit" or "exit".
-'''.format('%d.%d' % sys.version_info[:2]))
+        self.output.write(_introdoc())
 
     def list(self, items, columns=4, width=80):
         items = list(sorted(items))
diff --git 
a/Misc/NEWS.d/next/Documentation/2024-10-08-10-44-14.gh-issue-125142.HVlHrs.rst 
b/Misc/NEWS.d/next/Documentation/2024-10-08-10-44-14.gh-issue-125142.HVlHrs.rst
new file mode 100644
index 00000000000000..2340013f5de492
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Documentation/2024-10-08-10-44-14.gh-issue-125142.HVlHrs.rst
@@ -0,0 +1,2 @@
+As part of the builtin help intro text, show the keyboard shortcuts for the
+new, non-basic REPL (F1, F2, and F3).

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to