What do ellipsis […] mean in a list?

I was playing around in python. I used the following code in IDLE:

p  = [1, 2]
p[1:1] = [p]
print p

The output was:

[1, [...], 2]

What is this […]? Interestingly I could now use this as a list of list of list up to infinity i.e.

p[1][1][1]....

I could write the above as long as I wanted and it would still work.

EDIT:

  • How is it represented in memory?
  • What’s its use? Examples of some cases where it is useful would be helpful.
  • Any link to official documentation would be really useful.

5 Answers
5

Leave a Comment