使用 iPython 时如何向 python 解释器提供选项

How to supply options to the python interpreter when using iPython

例如,如果我想在使用通常的 python 命令时避免生成 .pyc 文件,我会写:

python -B script.py

但是如果我想改用 ipython 怎么办?我只知道

ipython -B script.py

不起作用

大多数 Python 解释器的命令行选项都有等效的 environment variables。这些将在启动 IPython.

时起作用

例如,为了避免编写字节码,您可以使用:

而不是 -B 标志
PYTHONDONTWRITEBYTECODE=1 ipython