Last active
June 1, 2021 14:28
-
-
Save dcramer/5094200 to your computer and use it in GitHub Desktop.
Python Standards (that I would change and enforce if I could)
This file contains 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
# dont do this | |
this_function_name(foo, bar | |
baz) | |
# do this | |
cramers_version( | |
foo, bar, baz) | |
# allow this | |
cramers_version(foo, bar, | |
baz) | |
# do this | |
foo( | |
'bar', | |
keyword='argument', | |
) | |
# dont do this | |
foo(hello='world', biz='baz', | |
foo='bar') | |
# do this | |
foo( | |
hello='world', | |
biz='baz', | |
foo='bar', | |
) |
This file contains 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
# dont do this | |
def my_func(): | |
"""lol this is bad""" | |
# dont do this | |
def my_func(): | |
"lol this is bad" | |
# dont do this | |
def my_func(): | |
"""lol this is bad | |
but worse | |
""" | |
# cramer's version | |
def my_func(): | |
""" | |
lol this is readable | |
no matter how many lines it is | |
""" | |
This file contains 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
# dont do this | |
foo = { | |
'foo': 'bar', | |
'baz': 'biz'} | |
# do this | |
foo = { | |
'foo': 'bar', | |
'baz': 'biz', # always have a trailing comma | |
} | |
# dont do this | |
foo = ('bar', 'baz', 'biz' | |
'lol', 'world') | |
# do this | |
foo = ( | |
'bar', | |
'baz', | |
'biz', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foo = {
'foo': 'bar',
'baz': 'biz', # always have a trailing comma
}
Agreed. Too bad trailing commas aren't valid JSON. It'd be nice if that changed so you could copy/paste between the two.