Skip to content

Instantly share code, notes, and snippets.

@syl20bnr
Last active August 29, 2015 14:06
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 syl20bnr/d464e62e061b2b39cfdf to your computer and use it in GitHub Desktop.
Save syl20bnr/d464e62e061b2b39cfdf to your computer and use it in GitHub Desktop.
# All of these examples are valid PEP-8
# Example #1
a = "a very long string with a lot of characters, more than the common 80 CPL limit."
# can be easily reformatted with parenthesis:
a = ("a very long string with a lot of characters, "
"more than the common 80 CPL limit.")
# or
a = '''a very long string with a lot of characters,
more than the common 80 CPL limit.'''
# Example #2
if a and b and c and d and e and f and g and h and i and j and k and l and m and n:
pass
# reformatted to:
if(a and b and c and d and e and
f and g and h and i and j and
k and l and m and n):
pass
# Example #3
from a.very.nested.module.withh.a.big.longg.name import A, Lot, Of, Classes, For, Fun, And, Prosperity
# can be reformatted without using backslashes:
from a.very.nested.module.withh.a.big.longg.name import (
A,
Lot,
Of,
Classes,
For,
Fun,
And,
Prosperity)
# So you get the point, use () to easily align the code in a PEP-8 compliante way.
# Note that {} and [] indentation rules behave like ()
# Please, avoid backslashes as much as possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment