Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Last active July 15, 2017 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kwpolska/8f0cf678b50f1737a1d6d66796217b99 to your computer and use it in GitHub Desktop.
Save Kwpolska/8f0cf678b50f1737a1d6d66796217b99 to your computer and use it in GitHub Desktop.
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