【问题标题】:Hiding extra imports from a package隐藏包中的额外导入
【发布时间】:2017-09-23 04:31:51
【问题描述】:

我有一个允许导入大量噪音的包。我曾尝试使用__all__ 之类的:

__all__ = ["WebdriverChauffeurMixin", "ChromeDriver", "FirefoxDriver"]

但这无济于事:

cchilders:~/projects/webdriver_chauffeur (master) 
$ pip uninstall webdriver-chauffeur
Can't uninstall 'webdriver-chauffeur'. No files were found to uninstall.

cchilders:~/projects/webdriver_chauffeur (master) 
$ pip uninstall webdriver_chauffeur
Can't uninstall 'webdriver-chauffeur'. No files were found to uninstall.

In [2]: from webdriver_chauffeur import 
BeautifulSoup            Keys                     os
By                       Select                   random
ChromeDriver             TimeoutException         subprocess
EC                       WebDriverWait            time
FirefoxDriver            WebdriverChauffeurMixin  webdriver

包在 pypi 上,但也在我的机器上~/projects/webdriver_chauffeur

包裹在https://github.com/codyc4321/webdriver_chauffeur

如何隐藏这些不必要的导入?

【问题讨论】:

  • 这看起来像是ipython 问题,而不是__all__ 问题。根据this GitHub issue,这种行为是configurable(尽管该选项已被弃用)。
  • 关心回答,我会接受

标签: python pip package pypi


【解决方案1】:

这看起来像是 ipython 问题,而不是 __all__ 问题。根据这个GitHub issue,这种行为是configurable(尽管该选项已被弃用)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多