← go back

more mutability weirdness I would like to abuse later

def test(foo = {}):
	def this():
		return foo
	def that():
		return foo
	return this, that

this_one  , that_one   = test({1: ["foo"]})
this_other, that_other = test({2: ["bar"]})
this_one().update(this_other())
this_one()[2].append("baz")
print(that_one(), that_other())
Jul 7, 2023, 2:07 PM
2 0 0

Comments