Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers | Privacy policy

Not logged in
Log in | Help
 

Style:Indentation

From 6.00 reference wiki

Elements of Style for Python Programmers: Main | Names | Variable Declarations | Indentation | Exceptions


Using IDLE: If you are using Idle, use the default indentation supplied by the editor. Usually, you will not have to edit this.

Indenting Manually: If indenting manually, use enough indentation -- each block should be indented by 4 spaces. Do not use tab characters for indentation.


Python doesn’t care how far you indent a block, but human readers do – one column isn’t enough, and 8 columns is usually too much, because it makes lines too long. Four spaces is just about right.

Never use tab characters for indentation. Tab characters may be interpreted inconsistently by text editors, printers, or display devices, causing inconsistent indentation (particularly when tabs and spaces are mixed together). Fortunately, with a good text editor, you can avoid tab characters without having to give up using the Tab key. Most programming editors can automatically insert the correct number of space characters when you press Tab key. IDLE does this automatically. Emacs will do it if you put (setq-default indent-tabs-mode nil) in your .emacs file.

Retrieved from "http://slice.csail.mit.edu../../../i/n/d/Style%7EIndentation_9b30.html"

This page has been accessed 25 times. This page was last modified 11:41, 6 February 2006 by 6.00 reference wiki user Asfandyar.


[Main Page]
Main Page
Recent changes

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports