如何在允许utf-8输入的同时获取交互式Python以避免使用readline?

时间:2021-05-24 07:12:22

I use a terminal (9term) that does command-line editing itself - programs that use readline just get in its way. It's fully utf-8 aware. How can I make an interactive python session disable readline while retaining utf-8 input and output?

我使用一个自己进行命令行编辑的终端(9term) - 使用readline的程序只会妨碍它。它完全是utf-8意识到的。如何在保留utf-8输入和输出的同时使交互式python会话禁用readline?

Currently I use:

目前我使用:

LANG=en_GB.UTF-8 export LANG
cat | python -i

however this causes sys.stdin.encoding to be None, which implies Ascii (the system default encoding, which doesn't seem to be changeable)

但这会导致sys.stdin.encoding为None,这意味着Ascii(系统默认编码,似乎不可更改)

TERM=dumb python

doesn't disable readline (and it mangles utf-8 input also).

不会禁用readline(它也会破坏utf-8输入)。

I'm new to python, so apologies if this is an obvious question.

我是python的新手,如果这是一个明显的问题,请道歉。

1 个解决方案

#1


In the past, I've disabled Python readline by rebuilding it from source: configure --disable-readline

在过去,我通过从源重建它来禁用Python readline:configure --disable-readline

This might be overkill, though, for your situation.

但是,对于您的情况,这可能是过度的。

#1


In the past, I've disabled Python readline by rebuilding it from source: configure --disable-readline

在过去,我通过从源重建它来禁用Python readline:configure --disable-readline

This might be overkill, though, for your situation.

但是,对于您的情况,这可能是过度的。