README
Put the following into your initialization file:
(setq py-install-
(add-to-list 'load-path py-install-
(require 'python-mode)
;;;;;;;;;
Customize default Python shell as `py-shell-name'
`py-shell-name' might be an installed executable as
shell command `type' would display, but also a
PATH/TO/(I)PYTHON, of a virtualenv for example
To change the Python default shell see also INSTALL
Most python-mode.el commands start with prefix `py-'
`M-x py- TAB'
displays a list of them in completion-buffer.
See also commands list delivered in directory doc.
List virtualenv related `M-x virtualenv- TAB'
resp. Pymacs commands `M-x pymacs-'
Commands related to a specific shell start with
it's name as `ipython-complete'.
Open an installed shell by
M-x SHELL
With prefix C-u user is prompted to specify a PATH-TO-LOCAL-SHELL
Also evaluating
(py-shell nil DEDICATED PATH-TO-
if DEDICATED is set to `t', shell will get an unique name.
Install a local shell by evaluating
(defun MY-LOCAL-SHELL ()
(interactive)
(py-shell nil DEDICATED PATH-TO-
;;;;;;;;;
Python code might be processed by an
- interactive Python shell (DEFAULT)
- non-interactive Python (`py-fast-
Both processes might run in
- session, i.e. start from possible previous state (DEFAULT)
- dedicated, (`py-dedicated-
There is also
- python-
;;;;;;;;;
To use auto-complete, just prepend the following lines:
(require 'auto-complete-
(ac-config-
or for company:
(autoload 'company-mode "company" nil t)
;;;;;;;;;
Beside common moves like `defun', `statement', block specific Python-mode edits are delivered:
`py-expression' and `py-partial-
Statement below is considered composed of two `py-expression'
a = ['spam', 'eggs', 100, 1234]
|_| |______
Assigment operator and all inside comments is ignored.
`py-partial-
a = ['spam', 'eggs', 100, 1234]
|_| |_____| |____| |__| |__|
|_
When traversing code, `py-partial-
all levels encountered, i.e. at opening `[' `py-expression' would return ['spam', 'eggs', 100, 1234], while one char behind at `''
it yields `'spam','
- py-sexp-function,
When set, it's value is called instead of `forward-sexp', `backward-sexp
Choices are py-partial-
;;;;;;;;;
Customize boolean `py-set-
If `t', enables use Python specific `fill-column' according to
`py-docstring-
and `py-comment-
Comment- and docstring settings might be disabled by
any non-integer value, which means: do not use a
different value of `fill-column' than emacs-wide
;;;;;;;;;
- Output
`py-execute-
`py-shell'. It's name is composed WRT to Python
version used, it's path etc.
Result of commands ending "-fast"
arrives in `py-output-buffer'
;;;;;;;;;
Python and IPython
Start IPython shell after loading python-mode via M-x
ipython, not from plain shell.
Executing code through IPython should work as with
regular Python, also getting completions from. However,
with IPython, it feels a demi-second slower. Also when
starting a session, first completion might fail, while
succeeding afterwards. Any bug reports, which might
help truck down the issue, are highly appreciated.
;;;;;;;;;
Troubleshooting
Start with Emacs -Q from the directory where python-mode.el lives.
Open python-mode.el and evaluate it.
Open a file with ending ".py".
M-x python RET
a regular Python-shell should appear
M-x IPython RET
an IPython-shell should be opened
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- Andreas Roehler
- Direction:
- Approved
- Assignee:
- None
- Definition:
- Approved
- Series goal:
- None
- Implementation:
-
Informational
- Milestone target:
- None
- Started by
- Andreas Roehler
- Completed by
- Andreas Roehler