News for hackers. Stuff that matters.
Re:So you think you know Python by kazinator on Friday October 09, 2020 @08:00PM (#24735622)
What you have is a circular structure. foo and bar are distinct objects, so foo == bar is false. However, they are similar objects: they have exactly the same structure. If we had a function for structural comparison which handles cycles, that function would have to conclude that foo and bar are structurally equal. This is because of symmetry in the cycle: bar[0] is foo and, symmetrically, foo[0] is bar. Both foo and bar are one-element lists whose elements are, respectively, bar and foo.

There are no comments on this comment yet.