Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save ksomemo/9155437 to your computer and use it in GitHub Desktop.

Select an option

Save ksomemo/9155437 to your computer and use it in GitHub Desktop.
>>> def side_effects_kwarg(kwarg = []):
... kwarg.append(1)
... return kwarg
...
>>> side_effects_kwarg()
Out[9]: [1]
>>> side_effects_kwarg()
Out[10]: [1, 1]
>>> side_effects_kwarg([])
Out[11]: [1]
>>> side_effects_kwarg()
Out[12]: [1, 1, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment