[HN Gopher] Why does a = a[0] = [0] create a self-referential li...
___________________________________________________________________
Why does a = a[0] = [0] create a self-referential list in Python?
Author : susam
Score : 11 points
Date : 2021-11-18 20:08 UTC (2 hours ago)
(HTM) web link (susam.in)
(TXT) w3m dump (susam.in)
| anitil wrote:
| I'm amazed at how long I've been working in python and never
| known that assignment works in this way. I suppose I just avoid
| parts of the language that I don't understand.
|
| Looking through the archives, it's a really interesting blog in
| general
| klyrs wrote:
| I mean, it generally looks like a terrible idea, so absent of
| malice to the reader (or code golf shenanigans) nobody would do
| this. Not a surprise that the behavior is surprising...
___________________________________________________________________
(page generated 2021-11-18 23:02 UTC)