11

I printed out the contents of a list, and i got the following output:

[[...], [...], [...], [...], [...], [...]]

What are these strange dots?

I used python 2.7.3

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Kompi
  • 484
  • 4
  • 18

1 Answers1

16

Probably you accidentally built a list containing a reference to itself (or here, lots of references):

>>> a = ['x']
>>> a
['x']
>>> a[0] = a
>>> a
[[...]]

The three dots are used so that the string representation doesn't drown in recursion. You can verify this by using id and the is operator:

>>> id(a)
165875500
>>> id(a[0])
165875500
>>> a is a[0]
True
DSM
  • 342,061
  • 65
  • 592
  • 494