Skip to content

Instantly share code, notes, and snippets.

@erip
Last active May 5, 2020 21:28
Show Gist options
  • Select an option

  • Save erip/42cb83e9a9b82e294cb338686f6563f6 to your computer and use it in GitHub Desktop.

Select an option

Save erip/42cb83e9a9b82e294cb338686f6563f6 to your computer and use it in GitHub Desktop.
Some dumb thing
class Something:
def __init__(*args, **kwargs):
pass
def foo(a=None, b=None, c=None, d=100):
# We can't add *args and Something specific **kwargs to above signature
# since *args need to come before **kwargs
something = Something()
#
def _foo_helper(a, b, c, d, *args, **kwargs):
something = Something(*args, **kwargs)
def foo2(*args, **kwargs):
a, b, c, d = kwargs.pop('a', None), kwargs.pop('b', None), kwargs.pop('c', None) kwargs.pop('d', 100)
_foo_helper(a, b, c, d, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment