3 ms·
Neat idea! Seems like the following less-confusing assignment also works: a = [0] a[0] = a
by cecilpl2 5y ago
Neat idea! Seems like the following less-confusing assignment also works:
a = [0]
a[0] = a
- tshaddox 5y agoYeah, this article is more about the chained assignment syntax in Python which might not be on the radar for a lot of Python coders. There’s nothing particularly interesting about the self-reference. You can do the same thing with bog-standard idiomatic code: just make an empty list and append it to itself.