Differences between revisions 6 and 7
Revision 6 as of 2007-06-02 15:02:16
Size: 1337
Editor: PaulBoddie
Comment: Added link to other "how to", fixed headings.
Revision 7 as of 2008-11-15 14:00:17
Size: 1337
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
[[TableOfContents]] <<TableOfContents>>

Python's syntax requires special handling in the construction of a Python editor mode. Two issues are particular to Python:

See also HowToEditPythonCode for concrete examples of editor configuration.

Indentation

Python uses indentation to group statements. A well designed mode should offer support for smart indentation of code. For example, a line beginning with the keyword def and ending with : should cause the editor to indent the following line upon hitting of the return key.

The most widely used standard is four-space indent. Using tabs is discouraged, so the editor should be configured to convert tabs to spaces.

Code examples or references on how to deal with indentation should follow.

Strings

Python supports three types of string literals. Strings can be enclosed in single quotes ('), double quotes (") and in groups of three single or double quotes (and are then referred to as triple-quoted strings). A well designed mode should support all three types. In particular, a mode should correctly recognize that triple-quoted strings can include unescaped newlines and quotes.

Python allows for raw strings without \-escape sequences (written with a preceding r: r"c:\dir1\dir2"). A well designed mode should support this feature as well.


CategoryEditors

EditorConfigurationHowto (last edited 2023-09-17 13:10:57 by MatsWichmann)

Unable to edit the page? See the FrontPage for instructions.