2 ms·
> If this new syntax fixes that, I see the value. It does. The old syntax creates and assigns the variable at compile-time. => does it at execution time. So
by Sohcahtoa82 5y ago
> If this new syntax fixes that, I see the value.
It does. The old syntax creates and assigns the variable at compile-time. => does it at execution time.
So this code:
def foo(bar, baz=[]):
baz.append(bar)
return baz
foo(1)
foo(2)
print(foo(3))
would print '[1, 2, 3]'
But this code:
def foo(bar, baz=>[]):
baz.append(bar)
return baz
foo(1)
foo(2)
print(foo(3))
would print '[3]'