python - 在 python 启动时自动加载模块

标签 python module autoload ipython

我希望 IPython 或 Python 解释器在我启动时自动加载模块。

这可能吗?

例如,当我启动 IPython 时:

$ ipython

...

>>> from __future__ import division
>>> from mymodule import *

In [1]:

类似于 SymPy's live shell在教程页面中找到。

最佳答案

在您的主目录中有一个 .pythonstartup 并在那里加载模块并将 PYTHONSTARTUP env 指向该文件。

该文件中的 Python 命令在第一个提示以交互模式显示之前执行。

我用它来在 python 解释器 shell 中启用命令行补全

关于python - 在 python 启动时自动加载模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4002924/

相关文章:

php - 用于应用程序文件的 Composer PSR-4

PHP - WordPress 插件命名空间中的 PSR-4 自动加载

python - 使用 SWIG 在 Python 中包装 C++ 类

javascript - 检查模块版本

python生成器垃圾收集

python - 导入 python 模块的特殊性?

python - 如何使用或安装pycocoevalcap?

php - 如何让 PHPUnit 在测试路径中排除 .svn 目录?

python - distutils - 如何在同一模块中获取扩展模块和 python 模块?

Python Selenium : Is there a way to install webdriver inside the virtual enviroment