Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Getting Python Code Indentation Right

Comments & Discussion

W Patrick Jones on April 22, 2019

Nothing on multi-line string assignements? That and really long SQL statements are the ones that always confuse me on where to indent.

Joe Tatusko RP Team on April 22, 2019

I usually bring the indent to the where the opening quotation character is on the next line to keep it in a nice block.

For the long SQL statements I’ll generally start a multiline string with nothing in the first line, then have everything non-indented to keep it grouped like it would be outside of Python (if I can’t use something like SQLAlchemy to be more Pythonic)

Become a Member to join the conversation.