>> dir(__builtins__) ['ArithmeticError', 'A-6ren">
gpt4 book ai didi

scheme - 在 Scheme 中的函数上获取交互式 "help"

转载 作者:行者123 更新时间:2023-12-02 06:22:55 29 4
gpt4 key购买 nike

在 Python 的交互式 shell 中,您可以使用 dir 命令获取内置函数列表(如果您知道在哪里查找)。

>>> 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', 'ZeroDivisionError', '__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']

一旦您知道函数名称,您就可以使用 help 命令获得任何函数的交互式帮助。

>>> 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.

在任何流行的 Scheme 开发环境中,Python 的交互式 help 命令是否有等效项? (我一直在 DrScheme 工作,但我愿意切换到 Racket、MITScheme 等,只要我仍然可以完成 SICP 中的所有练习并进行最少的调整。)

此外,是否有一个等效于 dir(__builtins__) 命令的命令将列出 Scheme 中定义的所有可用过程?如果能够快速判断为给定语言选择或给定包定义了什么,那就太好了。

最佳答案

这对于每个 Scheme 都是不同的(不像 Common Lisp,它内置了 describe)。例如,在 Chicken 中,您可以使用 chicken-doc扩展,让您可以从命令行和 REPL 浏览文档。

关于scheme - 在 Scheme 中的函数上获取交互式 "help",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6146583/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com