Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PEP8-compatible line continuation
if 1 == 1:
pass
elif 1 == 1 or \
1 == 2: # backslash continuation is very ugly
pass
elif (1 == 1 or # parentheses work better
1 == 2):
pass
elif (1 == 1 or # and they look best with 8 spaces
1 == 2):
pass
elif 1 == 1 or 1 == 2: # but the best thing to do: ignore length limit
# (Add E501 to ignore list now!)
pass
# with statements need this though if you limit line length:
with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment