This is part of the Emacs Starter Kit.
Support for the Python programming language.
Determine whether required packages are installed. If not, use ELPA to install them.
(dolist (package '(python-mode ipython))
(unless (package-installed-p package)
(package-install package)))
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
ipython
executable is on the path, then assume that IPython is
the preferred method python evaluation.
(when (executable-find "ipython")
(require 'ipython)
(setq org-babel-python-mode 'python-mode))
(when (require 'cython-mode nil 'no-error)
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . cython-mode))
(add-to-list 'auto-mode-alist '("\\.pxd\\'" . cython-mode))
(add-to-list 'auto-mode-alist '("\\.pxi\\'" . cython-mode)))