2019-01-16 14:31:52 +02:00
|
|
|
# Prelude Python
|
2013-10-07 20:33:02 +03:00
|
|
|
|
2020-04-08 10:15:30 +03:00
|
|
|
!!! Note
|
|
|
|
|
|
|
|
This module builds on top of the shared [Programming](programming.md) module.
|
|
|
|
|
2013-10-07 20:33:02 +03:00
|
|
|
## Python Mode
|
|
|
|
|
|
|
|
Emacs comes with Python programming support through the built-in
|
2020-04-08 10:15:30 +03:00
|
|
|
`python-mode`. Whenever you are editing Python code run `C-h m` to
|
2013-10-07 20:33:02 +03:00
|
|
|
look at the Python mode key bindings. Alternatively look at the
|
|
|
|
menu bar entries under Python. To toggle the menu bar press `F12`.
|
|
|
|
|
2020-10-07 10:35:27 +03:00
|
|
|
## Anaconda Mode
|
|
|
|
|
|
|
|
Prelude bundles the powerful
|
|
|
|
[anaconda-mode](https://github.com/pythonic-emacs/anaconda-mode),
|
|
|
|
which provides code navigation, documentation lookup and completion for Python.
|
|
|
|
|
|
|
|
Anaconda has integration with popular modes like `company` and `eldoc`.
|
|
|
|
|
2013-10-07 20:33:02 +03:00
|
|
|
## Syntax checking
|
|
|
|
|
|
|
|
Prelude ships with [Flycheck](https://github.com/flycheck/flycheck),
|
2013-10-10 17:29:56 +03:00
|
|
|
an on the fly syntax checker. Flycheck has support for two Python
|
2013-10-07 20:33:02 +03:00
|
|
|
syntax checkers, [Pylint](http://www.pylint.org/) and
|
|
|
|
[Flake8](http://flake8.readthedocs.org/en/latest/). In
|
|
|
|
order to have Flycheck support on the fly syntax checking for
|
|
|
|
Python you need to have either of these installed and accessible to
|
|
|
|
Emacs. In order to manually choose a checker run `C-c ! s`.
|
2020-10-07 10:21:20 +03:00
|
|
|
|
2020-10-07 10:35:27 +03:00
|
|
|
## Automatic insertion of file encoding comments
|
2020-10-07 10:21:20 +03:00
|
|
|
|
2020-10-07 10:35:27 +03:00
|
|
|
You can have Prelude auto-detect the encoding of a source buffer and
|
|
|
|
insert the appropriate `# coding:` comments. If you wish to enable
|
|
|
|
this, add the following to your configuration:
|
2020-10-07 10:21:20 +03:00
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
(setq prelude-python-mode-set-encoding-automatically t)
|
|
|
|
```
|
2020-10-07 10:35:27 +03:00
|
|
|
|
|
|
|
!!! Note
|
|
|
|
|
|
|
|
Previously `prelude-python` had this feature enabled by default (up to Prelude 1.1), but
|
|
|
|
it is only necessary on Python 2, because Python 3 uses utf-8
|
|
|
|
as the default file encoding. In 2020 Python 2 became deprecated, so that
|
|
|
|
functionality became mostly obsolete.
|