Instead of a list with some objects in it, I get [...]
whenever I run my code. I'd like to know what it means, in order to debug my code.
Asked
Active
Viewed 201 times
7

reynoldsnlp
- 1,072
- 1
- 18
- 45

Algunillo
- 83
- 5
-
http://stackoverflow.com/questions/772124/what-does-the-python-ellipsis-object-do – xiº Dec 01 '15 at 09:17
-
@xi_ That may be related but isn't quite what's happening with the OP. – SuperBiasedMan Dec 01 '15 at 09:34
2 Answers
14
That most probably is a reference to the object itself. Example:
In [1]: l = [0, 1]
In [2]: l.append(l)
In [3]: l
Out[3]: [0, 1, [...]]
In the above, the list l
contains a reference to itself. This means, you can endlessly print elements within it (imagine [0, 1, [0, 1, [0, 1, [...]]]]
and so on) which is restricted using the ...
IMO, you are incorrectly appending values somewhere in your code which is causing this.
A more succinct example:
In [1]: l = []
In [2]: l.append(l)
In [3]: l
Out[3]: [[...]]

Anshul Goyal
- 73,278
- 37
- 149
- 186
-
Fun stuff, `l[2][2][2][2][2]` (and so on) returns the same as just `l` (upper example) :-) – adrianus Dec 01 '15 at 09:16
-
2
>>> data = []
>>> data.append([1,3,4])
>>> data
[[1, 3, 4]]
>>> data.append([1,3,data])
>>> data
[[1, 3, 4], [1, 3, [...]]]
>>> data[0]
[1, 3, 4]
>>> data[1]
[1, 3, [[1, 3, 4], [...]]]
>>> data.append([1,2,data])
>>> data
[[1, 3, 4], [1, 3, [...]], [1, 2, [...]]]
>>> data[2]
[1, 2, [[1, 3, 4], [1, 3, [...]], [...]]]
Then it just gets weird

Rolf of Saxony
- 21,661
- 5
- 39
- 60