Skip to content

Files

Latest commit

 

History

History
32 lines (20 loc) · 696 Bytes

multiple-statements.md

File metadata and controls

32 lines (20 loc) · 696 Bytes

Pattern: Multiple statements in one line

Issue: -

Description

Python syntax does permit more than one statement on a line, separated by semicolon (;). However, limiting each line to one statement makes it easier for a human to follow a program's logic when reading through it.

Compound statements are also discouraged by PEP 8 style guide.

Example of incorrect code:

if foo == 'bar': init()
do_one(); do_two(); do_three()

Example of correct code:

if foo == 'bar':
    init()
do_one()
do_two()
do_three()

Further Reading