Can someone explain this?
>>> x=x[0]=[0]
>>> x
[[...]]
>>> x is x[0]
True
>>> x[0][0][0][0][0][0][0]
[[...]]
>>> x in x
True
what is [...]?
When two objects in Python holds reference of each other, it is known as circular reference. Circular reference could cause memory leak in Python versions below 3.4. We as good programmers, should use weak references to create circular reference to prevent potential leak of memory. I am an engineer by education and writer by passion.
Circular Linked Lists are data structures that are used to store lists. It is very similar to linked lists but with a few extra features. In this tutorial, we will discuss what a circular linked list is, we will implement it in python and see its output. We must first define linked lists before moving on to circular linked lists.
There’s a head that points to the start of the list which is used to enter the list and iterate through the circular linked list. To create a circular linked list, we create two classes: the first one for nodes and the second one for the linked list that will use the nodes.
In this class, there are two attributes, the data that is present in the node, and the access to the next node of the linked list. In a circular linked list, the head and the rear are adjacent to each other.
That's just Python telling you that you have a circular reference; it's smart enough not to enter an infinite loop trying to print it out.
It's output by the method responsible for generating the representation of the structure. It represents a recursive structure, elided since it can be nested infinitely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With