This is part of the Emacs Starter Kit.
Support for the Python programming language.
Replace the Python mode that comes with Emacs by the Python mode supplied by the Python distribution itself.
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(setq org-babel-python-mode 'python-mode)
(defun python-use-ipython (cmd args)
(setq ipython-command cmd)
(setq py-python-command-args args)
(require 'ipython)
(setq ipython-completion-command-string
"print(';'.join(__IP.Completer.all_completions('%s')))\n"))
In your personal configuration, add something like this to use IPython:
(python-use-ipython "/usr/local/bin/ipython" '("-colors" "LightBG" "-nobanner"))
(require 'cython-mode)
(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))