Running Python Programs from Emacs

http://www.bnikolic.co.uk/blog/python-running-emacs.html

Tips on running python from Emacs.

Setting-up

Python interpreter to use

If you have more than one version of python installed on your system you may want to tell emacs which one of those to use. The python interpreter that emacs will use is controlled by the py-python-command variable. You can set it with:

(setq py-python-command "/usr/local/bin/python2.3")

Associating files with python

Emacs will normally associate files ending with .py with python and enter python-mode if you open (visit) these files. You can associate other files with python through the use of the auto-mode-alist variable.

For example, scons is a popular build environment tool built on top of python. Its configuration files are in python themselves, so it is useful to be able to edit them in python-mode. This can be arranged by placing the following into your .emacs file:

(setq auto-mode-alist
      (cons '("SConstruct" . python-mode) auto-mode-alist))

Shell Environment

You can adjust the shell environment under which the python interpreter will run, including the content of thePYHTONPATH variable, using commands described in this entry.

Keystrokes

All of these work only in Python-mode, i.e., if you've open a file with a suffix .py.

  • C-c ! to start a python interpreter as a sub-process, or if already started, to switch to this buffer.
  • C-c C-c to send the entire current file to the interpreter
  • C-M-x to send the current function definition the interpreter
  • C-c ret to reload current file as python module

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值