Skip to content

Instantly share code, notes, and snippets.

@dcramer

dcramer/args.py

Last active Feb 16, 2021
Embed
What would you like to do?
Python Standards (that I would change and enforce if I could)
# 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',
)
# 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
"""
# 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',
)
@krimkus

This comment has been minimized.

Copy link

@krimkus krimkus commented Mar 6, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment