if (this_is_one_thing and that_is_another_thing): do_something() # Add a comment, which will provide some distinction in editors # supporting syntax highlighting.
if (this_is_one_thing and that_is_another_thing): # Since both conditions are true, we can frobnicate.
In the event of any conflicts, such project-specific guides take precedence for that project. However, know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. When using a hanging indent the following should be considered; there should be no arguments on the first line and further indentation should be used to clearly distinguish itself as a continuation line. foo = long_function_name(var_one, var_two, var_three, var_four) # More indentation included to distinguish this from the rest.
One of Guido's key insights is that code is read much more often than it is written. def long_function_name( var_one, var_two, var_three, var_four): print(var_one) # Hanging indents should add a level.
The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Python code. foo = long_function_name( var_one, var_two, var_three, var_four) # Arguments on first line forbidden when not using vertical alignment.
foo = long_function_name(var_one, var_two, var_three, var_four) # Further indentation required as indentation is not distinguishable.
def long_function_name( var_one, var_two, var_three, var_four): print(var_one) ), plus a single space, plus an opening parenthesis creates a natural 4-space indent for the subsequent lines of the multiline conditional.
This can produce a visual conflict with the indented suite of code nested inside the -statement, which would also naturally be indented to 4 spaces.
This PEP takes no explicit position on how (or whether) to further visually distinguish such conditional lines from the nested suite inside the # No extra indentation.
This document gives coding conventions for the Python code comprising the standard library in the main Python distribution.
Please see the companion informational PEP describing style guidelines for the C code in the C implementation of Python  .
This document and PEP 257 (Docstring Conventions) were adapted from Guido's original Python Style Guide essay, with some additions from Barry's style guide  .
This style guide evolves over time as additional conventions are identified and past conventions are rendered obsolete by changes in the language itself. In particular: do not break backwards compatibility just to comply with this PEP!