【问题标题】:Use `dir()` to just retrieve the `__all__` list from `__init__.py`使用 `dir()` 从 `__init__.py` 中检索 `__all__` 列表
【发布时间】:2021-05-20 21:31:24
【问题描述】:

一旦我使用下面的格式加载了一个包,有没有办法使用dir() 来列出__init__.py__all__ 列表中的值而不使用列表理解正则表达式?

from featurestore import featurestore as fs

我知道这是一个简单的问题,只是很难找到答案。

【问题讨论】:

  • 只导入?! from featurestore import __all__

标签: python-3.x package


【解决方案1】:

使用@SvenEberth 的建议,以下内容对我有用:

from featurestore import __all__ as fs_listing
print(fs_listing)

【讨论】:

    猜你喜欢
    • 2022-01-06
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    相关资源
    最近更新 更多