Last active
August 29, 2015 14:06
-
-
Save syl20bnr/d464e62e061b2b39cfdf to your computer and use it in GitHub Desktop.
Indentation examples in Python for discussion http://lists.numenta.org/pipermail/nupic-hackers_lists.numenta.org/2014-September/002616.html
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
# 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