【问题标题】:Retrieve all builtin functions检索所有内置函数
【发布时间】:2017-08-06 04:36:45
【问题描述】:

我打算检索2. Built-in Functions 中指定的默认内置函数列表

如何全部列出?

就像列出所有关键字一样:

python
import keyword
keyword.kwlist

是否可以列出所有 68 个函数?


这是我关于 SO 的第一个问题,请注意,它绝对不会复制到 stackoverflow 甚至世界上的现有内容。

我的问题是关于文档列出的与dir(__builtins__) 完全不同的 68 个内置函数:

【问题讨论】:

    标签: python function built-in


    【解决方案1】:

    这将显示所有内置函数:

    >>> dir(__builtins__)
    ['ArithmeticError', 'AssertionError', ...,  'type', 'vars', 'zip']
    

    【讨论】:

    • @cᴏʟᴅsᴘᴇᴇᴅ:不幸的是,我还完全了解该站点上的每个 Python 问题。
    • 如果不是重复的,您可能需要查看this
    • dir(builtins) 列出所有 151 个内置库,也不显示 68 个函数。 @IgnacioVazquez-Abrams
    • 问题没有重复,看我的回答@cᴏʟᴅsᴘᴇᴇᴅ
    • 我在此处标记的问题中存在完全相同的答案。重复的答案很好。
    【解决方案2】:
    class BuiltinFunctions_42:
        def __init__(self):
            self.in = ['input']
            self.file = ['open']
            self.number =  ['hex', 'oct', 'abs', 'round', 'divmod', 'pow', 'sum']
            self.string =  ['format', 'ord', 'chr', 'ascii', 'bin']
            self.obj = ['id']
            self.sequence = ['hash', 'len', 'max', 'min']
            self.iterator = ['all', 'any','iter', 'next']
            self.function = ['callable']
            self.code =  ['eval', 'exec', 'compile']
            self.klass = ['__build_class__', 'issubclass']
            self.instance = ['repr','isinstance', 'hasattr',  'getattr', 'setattr', 'delattr']
            self.module = ['__import__']
    
            self.dubug = {'introspection':{'locals', 'globals'}}
            self.out = ['print', 'dir', 'vars']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 2018-05-06
      相关资源
      最近更新 更多