Difference between revisions of "Python"

From WikEmacs
Jump to navigation Jump to search
(Section "all in one" and a word about elpy)
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
= Default modes =
 +
 +
There are a number of python modes for Emacs.
 +
fgallina's [https://github.com/fgallina/python.el python.el] is the python.el included in Emacs 24.2 and onwards.
 +
 +
= External extensions =
 +
 
== rope & ropemacs ==
 
== rope & ropemacs ==
  
'''rope''' is a library for refactoring and manipulating Python code. {{ModeLink|ropemacs}} is an Emacs interface to the rope library.
+
'''rope''' is a library for refactoring and manipulating Python code. '''{{ModeLink|ropemacs}}''' is an Emacs interface to the rope library.
  
 
[http://rope.sourceforge.net/ rope homepage]
 
[http://rope.sourceforge.net/ rope homepage]
  
 
[http://rope.sourceforge.net/ropemacs.html ropemacs homepage]
 
[http://rope.sourceforge.net/ropemacs.html ropemacs homepage]
 +
 +
== Flymake ==
 +
 +
[[Flymake|flymake]] is a on-the-fly syntax checker for Emacs.
 +
We can use it alongside with [[flyspell|flyspell]].
 +
 +
To run pep8, pylint, pyflakes and unit-tests (with nose), you can be interested in using [https://github.com/akaihola/flymake-python flymake-python].
  
 
== Pymacs ==
 
== Pymacs ==
  
'''Pymacs''' is an Emacs extension that enables the use of Python alongside with Emacs Lisp.
+
'''{{ModeLink|Pymacs}}''' is an Emacs extension that enables the use of Python alongside with Emacs Lisp.
  
 
[http://pymacs.progiciels-bpi.ca/index.html Pymacs homepage]
 
[http://pymacs.progiciels-bpi.ca/index.html Pymacs homepage]
 +
 +
 +
 +
== Ipdb, ipython debugger ==
 +
 +
If you call ipdb, the execution will stop and give a nice ipython-looking prompt.
 +
Just add `import ipdb; ipdb.set_trace()`
 +
 +
You can use the following to highlight this line, and not forget it :
 +
<source lang="scheme">
 +
; Highlight the call to ipdb
 +
; src http://pedrokroger.com/2010/07/configuring-emacs-as-a-python-ide-2/
 +
(defun annotate-pdb ()
 +
  (interactive)
 +
  (highlight-lines-matching-regexp "import ipdb")
 +
  (highlight-lines-matching-regexp "ipdb.set_trace()"))
 +
(add-hook 'python-mode-hook 'annotate-pdb)
 +
</source>
 +
 +
== pdb track ==
 +
 +
If you use emacs-for-python given above, you can track your source code while debugging with pdbtrack.
 +
 +
A tool to use in a non-emacs terminal would be [https://pypi.python.org/pypi/pdbpp/ pdbpp]
 +
 +
= All-in-one solutions =
  
 
== emacs-for-python ==
 
== emacs-for-python ==
Line 18: Line 58:
  
 
[https://github.com/gabrielelanaro/emacs-for-python/ emacs-for-python at github]
 
[https://github.com/gabrielelanaro/emacs-for-python/ emacs-for-python at github]
 +
 +
== Elpy ==
 +
 +
'''Elpy''' is a collection of elisp packages for Python too.
 +
 +
https://github.com/jorgenschaefer/elpy/wiki/Features
 +
 +
 +
= See also =
 +
 +
You'll be certainly interested in :
 +
 +
=== Magit, a git interface ===
 +
 +
Emacs + git is magic : [[magit]]
 +
 +
=== Yasnippet, a template system ===
 +
 +
[[yasnippet]]
 +
 +
=== ELPA packages ===
 +
 +
If you're running Emacs 24, check out some [[ELPA]] packages:
 +
; {{Command | list-packages}}  :  and see flymake-pyhon-pyflakes, flymake-shell, virtualenv, abl-mode (a python TDD minor-mode), jedi (a python auto-completion for emacs), nose (easy python test-running in emacs), pyregexp, python-magic and more.
  
 
[[Category:Programming languages]]
 
[[Category:Programming languages]]

Revision as of 12:25, 24 May 2013

Default modes

There are a number of python modes for Emacs. fgallina's python.el is the python.el included in Emacs 24.2 and onwards.

External extensions

rope & ropemacs

rope is a library for refactoring and manipulating Python code. ropemacs is an Emacs interface to the rope library.

rope homepage

ropemacs homepage

Flymake

flymake is a on-the-fly syntax checker for Emacs. We can use it alongside with flyspell.

To run pep8, pylint, pyflakes and unit-tests (with nose), you can be interested in using flymake-python.

Pymacs

Pymacs is an Emacs extension that enables the use of Python alongside with Emacs Lisp.

Pymacs homepage


Ipdb, ipython debugger

If you call ipdb, the execution will stop and give a nice ipython-looking prompt. Just add `import ipdb; ipdb.set_trace()`

You can use the following to highlight this line, and not forget it :

; Highlight the call to ipdb
; src http://pedrokroger.com/2010/07/configuring-emacs-as-a-python-ide-2/
(defun annotate-pdb ()
  (interactive)
  (highlight-lines-matching-regexp "import ipdb")
  (highlight-lines-matching-regexp "ipdb.set_trace()"))
(add-hook 'python-mode-hook 'annotate-pdb)

pdb track

If you use emacs-for-python given above, you can track your source code while debugging with pdbtrack.

A tool to use in a non-emacs terminal would be pdbpp

All-in-one solutions

emacs-for-python

emacs-for-python is a bundle of the above modes (and more), and it's an easy way to turn Emacs into a Python IDE.

emacs-for-python at github

Elpy

Elpy is a collection of elisp packages for Python too.

https://github.com/jorgenschaefer/elpy/wiki/Features


See also

You'll be certainly interested in :

Magit, a git interface

Emacs + git is magic : magit

Yasnippet, a template system

yasnippet

ELPA packages

If you're running Emacs 24, check out some ELPA packages:

M-x list-packages
and see flymake-pyhon-pyflakes, flymake-shell, virtualenv, abl-mode (a python TDD minor-mode), jedi (a python auto-completion for emacs), nose (easy python test-running in emacs), pyregexp, python-magic and more.