增加IPython历史记录长度

时间:2015-10-09 08:26:26

标签: python ipython input-history

我试过在这篇文章后增加IPython历史记录长度: c.TerminalInteractiveShell.history_length更改了~/.ipython/profile_default/ipython_config.py中的print('test-startup')

配置文件好像是在启动时执行的(如果我将echo $HISTSIZE; echo $HISTFILESIZE放在文件中,当我启动IPython时会打印它)

但它似乎没有任何影响,无论如何都要从ipython内部查看历史记录大小(有点像你在bash中如何做>>> import itertools >>> { x: map(lambda x:x[1], y) for x,y in itertools.groupby(sorted(original_list, key=lambda x:x[0]), key=lambda x:x[0])} {'a': [1, 2, 3, 4], 'c': [7, 8, 9, 0], 'b': [5, 6]} ?)

2 个答案:

答案 0 :(得分:9)

使用

id

答案 1 :(得分:2)

在尝试自己回答这个问题时,我偶然发现了这个问题as well this question并找到了一些片段,这些片段确实没有为OP提供完整的TL; DR信息。

因此,对于我自己的记录并在SO上做出更完整的答案,我提供了一个快速实施并检查"增加iPython历史记录长度。"

生成iPython配置文件

$ ipython profile create <profile name>

我只想把它作为我的默认配置,所以我跑了:

$ ipython profile create

修改ipython_config.py文件

运行上述命令会创建一个ipython_config.py文件,该文件(*.nix存储在~/.ipython/profile_default/ipython_config.py

这两行我取消注释并更改了以下值:

enter image description here

检查以确保实施工作

启动iPython并运行上面接受的答案中找到的命令,以确保新的history_length = 100,000

benjamingross (develop*)$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:14:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %config TerminalInteractiveShell.history_length
Out[1]: 100000
相关问题