标签: ptpython

如何检查您正在使用的 REPL 类型?

Python REPL 有很多种,比如默认的 REPL、ptpython、ipython、bpython 等。当我已经使用 REPL 时,有没有办法检查当前的 REPL 是什么?

一点背景知识:
正如您可能已经听说的,我制作了pdir2来生成漂亮的dir()打印。我面临的一个挑战是使其与那些第三方 REPL 兼容,但首先我需要知道程序在哪个 REPL 中运行。

python ipython bpython read-eval-print-loop ptpython

5
推荐指数
1
解决办法
355
查看次数

如何在ptpython控制台中读取历史记录?

我一直试图弄清楚如何在控制台中保存和读取 Python 命令的历史记录ptpython,但一直无法做到这一点。到目前为止,我所有的努力都是这个答案的变体。然而,我仍然无法阅读我的历史。

\n

我只是希望能够按\xe2\x86\x91\xe2\x86\x93箭头来浏览上一个控制台会话(而不是我所在的当前控制台会话)中的 Python 命令。这是我的$PYTHONSTARTUP文件中当前的内容:

\n
# Add auto-completion and a stored history file of commands to your Python\n# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is\n# bound to the Esc key by default (you can change it - see readline docs).\n#\n# Store the file in ~/.pystartup, and set an environment variable to point\n# to it:  "export PYTHONSTARTUP=/home/user/.pystartup" in bash.\n#\n# Note that PYTHONSTARTUP does *not* expand …
Run Code Online (Sandbox Code Playgroud)

python console python-3.x ptpython

4
推荐指数
1
解决办法
893
查看次数