python-mode+emacs24.1的execfile问题解决

来源:互联网 发布:计算机基础与c语言 编辑:程序博客网 时间:2024/05/16 17:05

python-mode使用中,打开文件xxx.py输入python语句,按“ctrl+c ctrl+c”,会出现分割栏,并显示输出结果。

但安装python3.2后,输出会有:execfile

“filename cant find”的问题,网上网址

“https://bugs.launchpad.net/python-mode/+bug/450552”

或“http://mail.python.org/pipermail/python-list/2009-October/553535.html”,

解决办法为:修改python-mode.el文件的函数

“py-execute-file”中(cmd (format "execfile(r'%s') # PYTHON-MODE\n" filename))语句

改为(cmd (format "exec(compile(open('%s').read(), '%s', 'exec')) #

PYTHON-MODE\n" filename filename))

并将将其它所有“execfile”替换为“exec”,

经试验win7+emacs24.1+python3.2+python-mode-6.0-10版本成功。
2013