Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Teino1978-Corp/c8db72abe4a83308249e to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/c8db72abe4a83308249e to your computer and use it in GitHub Desktop.
"def foo(bar=[])" explained
lst = []
def foo1(bar=lst):
bar.append(1)
print(bar)
foo1()
foo1()
foo1()
def foo2(bar):
bar.append(1)
print(bar)
foo2(lst)
foo2(lst)
foo2(lst)
class Foo:
bar = []
ham = Foo()
spam = Foo()
ham.bar.append(1)
print(spam.bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment