5

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 [...]?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Jim Simons
  • 53
  • 3

3 Answers3

15

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.

DNS
  • 37,249
  • 18
  • 95
  • 132
4

iPython will do this:

[<Recursion on list with id=38505216>]

It's the same thing; the interpreter telling you that you have a recursive data structure.

nmichaels
  • 49,466
  • 12
  • 107
  • 135
3

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.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358