In Python's interactive shell you can get a list of built-in functions (if you know where to look) using the dir
command.
>>> dir(__builtins__)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisio开发者_开发百科nError', '__build_class__', '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
Once you know the function names you can get interactive help on any function using the help
command.
>>> help(input)
Help on built-in function input in module builtins:
input(...)
input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading.
Is there any equivalent for Python's interactive help
command in any of the popular Scheme development environments? (I've been working in DrScheme, but I'd be willing to switch to Racket, MITScheme, etc. as long as I can still complete all the exercise in SICP with minimal readjustment.)
Also, is there an equivalent of the dir(__builtins__)
command that will list all of the available procedures defined in Scheme? It would be nice to be able to quickly tell what's defined for a given language selection or for a given package.
This will be different for each Scheme (unlike Common Lisp, which has describe built in). In Chicken, for example, you can use the chicken-doc extension which let's you explore documentation from both the command line and REPL.
Updated answer: since I wrote the above answer, I've integrated that "interactive hack" into the main tree (available via the nightly builds, and will be part of the next Racket release (next October)). The answer to this, in the context of Racket is now:
Install
xrepl
-- the easiest way is to(require xrepl)
and then use the,install!
command to install it in your initialization file.The answer to the first part of your question is now the
,doc
command: just use any bindings and you'll get a browser window on its documentation.The answer to the second part is to use
,ap
-- with no arguments you'll see all of the identifiers that are available in your current namespace, and with an argument it will show only matching names.
For Racket, you can use the namespace-mapped-symbols
function. For example, see my "interactive hack" which gives you special REPL commands including ,apropos
to search through the current known bindings. (See the file for instructions on how to use it.)
In MIT Scheme:
(environment-bindings system-global-environment)
精彩评论