]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add new built-in 'help' which invokes pydoc.help (with a twist).
authorGuido van Rossum <guido@python.org>
Tue, 12 Jun 2001 16:48:52 +0000 (16:48 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 12 Jun 2001 16:48:52 +0000 (16:48 +0000)
Lib/site.py
Misc/NEWS

index 73b32812b9f1fd8777f030c79cb7184ef317f7a7..b8174f978b638450631cdd7d983aa7891f153b20 100644 (file)
@@ -236,6 +236,20 @@ __builtin__.license = _Printer(
     [os.path.join(here, os.pardir), here, os.curdir])
 
 
+# Define new built-in 'help'.
+# This is a wrapper around pydoc.help (with a twist).
+
+class _Helper:
+    def __repr__(self):
+        return "Type help() for interactive help, " \
+               "or help(object) for help about object."
+    def __call__(self, *args, **kwds):
+        import pydoc
+        return pydoc.help(*args, **kwds)
+
+__builtin__.help = _Helper()
+
+
 # Set the string encoding used by the Unicode implementation.  The
 # default is 'ascii', but if you're willing to experiment, you can
 # change this.
index 16850aac686cebcb55e8497db46ca8a28963706f..2bf6be49fed69270aa0cc691ee608348879af5b5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -151,6 +151,11 @@ Library
   In standard mode, 'q' and 'Q' are supported on all platforms, and are
   8-byte integral types.
 
+- The site module installs a new built-in function 'help' that invokes
+  pydoc.help.  It must be invoked as 'help()'; when invoked as 'help',
+  it displays a message reminding the user to use 'help()' or
+  'help(object)'.
+
 Tests
 
 - New test_mutants.py runs dict comparisons where the key and value