Skip to content

Instantly share code, notes, and snippets.

@glyphobet
Last active December 20, 2015 11:09
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 glyphobet/6120800 to your computer and use it in GitHub Desktop.
Save glyphobet/6120800 to your computer and use it in GitHub Desktop.
# Like this:
def function(
arg, kurz="klein",
really_long_argument_name="really long default value",
):
my_result = do_something(
# multiple short arguments on the same line are ok
arg, kurz=kurz,
really_long_argument_name=do_something_else(
one,
a_number_that_comes_between_one_and_three,
three, # trailing comma, always
), # closing parenthesis matches indentation of opening one
etc={
# Same for dicts & lists
really_long_key="really long value",
short="value",
},
)
# Not like this:
def function(arg, kurz="klein",
# Indented 13 spaces? Now when I rename function or move it into a class, I have to fix indentation on this line too
really_long_argument_name="really long default value"):
my_result = do_something(arg, kurz=kurz,
# And the lines are still over 79 characters, despite the breaks
really_long_argument_name=do_something_else(one,
a_number_that_comes_between_one_and_three,
three)
etc={really_long_key="really long value", # it's hard to re-order items in the dict
short="value"}) # and what function call is being terminated with this parenthesis?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment