A comprehensive guide covering Python code indentation across different development environments. Explains how Python-aware IDEs like PyCharm and VS Code handle indentation automatically, how to configure extensible editors like Vim and Emacs, and how to manually indent in basic text editors. Demonstrates using code formatters (Black, Ruff, autopep8) to automatically enforce PEP 8's four-space indentation standard. Clarifies why Python requires indentation as part of its syntax for statement grouping, unlike languages that use braces.

14m read timeFrom realpython.com
Post cover image
Table of contents
Python-Aware EditorsExtensible EditorsSimple Text Editors

Sort: