IPython在无缓冲模式下

时间:2009-10-16 14:57:13

标签: python ipython

有没有办法在无缓冲模式下运行IPython?

python -u相同,为标准python shell提供了无缓冲的IO

2 个答案:

答案 0 :(得分:1)

来自Python的手册页:

   -u     Force  stdin,  stdout and stderr to be totally unbuffered.  On systems where it matters, also put stdin, stdout and
          stderr in binary mode.  Note that there is internal buffering in xreadlines(), readlines() and  file-object  itera‐
          tors  ("for  line in sys.stdin") which is not influenced by this option.  To work around this, you will want to use
          "sys.stdin.readline()" inside a "while 1:" loop.

如果使用无缓冲模式会干扰readline,那么它肯定会干扰iPython为您提供的所有魔法编辑和自动完成功能。我倾向于怀疑这就是为什么命令行选项不在iPython中。

答案 1 :(得分:0)

尝试:

python -u `which ipython`

不确定它是否会起作用。