Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 1.09 KB

notes.md

File metadata and controls

24 lines (21 loc) · 1.09 KB

LINE CONTINUATION IN PYTHON

PEP8's E128: continuation line under-indented for visual indent? Two ways to continue lines with opening parenthesis

e.g

urlpatterns = patterns(' ', url(r'^$', listing, name='investment-listing')
print('\n'.join([" ".join(["{:d}".format(item) for item in row]) for row in matrix])) too long right?

  1. indenting to the opening bracket
  • print('\n'.join([" ".join(["{:d}".format(item)
    _____________________for item in row]) for row in matrix]))
  1. no arguments on starting line, then indenting to a uniform level(if no other opening parethesis is present before breaking))
  • urlpatterns = patterns(
    _____' ',
    _____url(r'^$', listing, name='investment-listing')
    OR(if other parenthesis are opened before breaking follow rule 1 with rule 2)

print(
___'\n'.join([" ".join(["{:d}".format(item)[normal indentation of 4 spaces here]
___________for item in row]) for row in matrix]))[indent to parenthesis)

Note: backslash \ can also be used for line breaks or continuation
__ represent spaces