Last active
July 15, 2017 08:37
-
-
Save Kwpolska/8f0cf678b50f1737a1d6d66796217b99 to your computer and use it in GitHub Desktop.
PEP8-compatible line continuation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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