我使用 bpython 进行交互式 Python session ,自从我更新了系统后,我遇到了以下问题:
在 bpython3 中:
>>> import sys
>>> sys.stdout.flush
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'FakeStream' object has no attribute 'flush'
但是,在Python3中:
>>> import sys
>>> sys.stdout.flush
<built-in method flush of _io.TextIOWrapper object at 0x7fab6b7fb708>
IPython3 也是如此。
那么为什么bpython3中sys.stdout
没有属性flush
呢?我搜索了sys
模块的源代码,但没有找到。我也找不到 sysmodule.c 文件或类似的文件。 bpython 是否对该模块使用与其他 CLI 相同的代码?
$ bpython3 --version
bpython version 0.12 on top of Python 3.4.2
(C) 2008-2012 Bob Farrell, Andreas Stuehrk et al. See AUTHORS for detail.
$ python3 --version
Python 3.4.2
最佳答案
这是一个错误,已在版本 0.13 中修复。
使用 pip3 install -U bpython
升级应该更新到包含修复程序的最新稳定版本。
关于python - sys.stdout 在 bpython 中没有刷新属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28714581/