Man*_*Dee 3 python readline python-2.7
我的Python历史文件存在于〜/ .pyhistory中,包含以下内容:
from project.stuff import *
quit()
from project.stuff import *
my_thing = Thing.objects.get(id=21025)
my_thing
my_thing.child_set.all()
my_thing.current_state
my_thing.summary_set
my_thing.summary_set.all()
[ x.type for x in my_thing.child_set.all() ]
[ x.type for x in my_thing.child_set.all().order_by( 'datesubmitted' ) ]
quit()
Run Code Online (Sandbox Code Playgroud)
我正在使用virtualenv和virtualenvwrapper来构建虚拟环境.今天我遇到了readline没有在我的历史文件中读取的问题:
>>> historyPath
'/Users/johndoe/.pyhistory'
>>> readline.read_history_file(historyPath)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
该文件是可读写的:
[johndoe@here]# ls -l ~/.pyhistory
-rw------- 1 johndoe somegroup 325 21 Sep 2012 /Users/johndoe/.pyhistory
Run Code Online (Sandbox Code Playgroud)
什么可能导致这个问题?
Man*_*Dee 19
您的历史记录文件似乎是旧版本.尝试将其转换为更高版本的readline所期望的格式,最值得注意的是第一行应该是字面上的'_HiStOrY_V2_',并且所有空格都应该替换为'\ 040':
_HiStOrY_V2_
from\040project.stuff\040import\040*
quit()
from\040project.stuff\040import\040*
my_thing\040=\040Thing.objects.get(id=21025)
my_thing
my_thing.child_set.all()
my_thing.current_state
my_thing.summary_set
my_thing.summary_set.all()
[\040x.type\040for\040x\040in\040my_thing.child_set.all()\040]
[\040x.type\040for\040x\040in\040my_thing.child_set.all().order_by(\040'datesubmitted'\040)\040]
quit()
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是底层readline/libedit库或Python readline模块的怪癖,但这对我有用.
| 归档时间: |
|
| 查看次数: |
1652 次 |
| 最近记录: |