2

Is the colon :, when used in slices in Python, called anything special? Other than, say, the slightly medicinal sounding "colon operator"?

x = s[:5]
    # ^ this character
Michael M.
  • 10,486
  • 9
  • 18
  • 34
Mr Mystery Guest
  • 1,464
  • 1
  • 18
  • 47
  • 2
    you could call it slice: http://stackoverflow.com/questions/509211/explain-pythons-slice-notation – toine Nov 04 '15 at 11:38
  • 2
    I'm not sure I've ever heard it referred to as anything in particular, and it's not named in [the language reference](https://docs.python.org/2/reference/expressions.html#slicings). It's incorrect to call it an operator, though; it's just a delimiter for the bounds and stride. – jonrsharpe Nov 04 '15 at 11:40
  • 1
    It's normally just called a colon. I guess you could call it a "slice colon" if you want to be specific. It's not actually an operator, it's a [delimiter](https://docs.python.org/3/reference/lexical_analysis.html?delimiters#delimiters). – PM 2Ring Nov 04 '15 at 11:45
  • 1
    Maybe `slice delimiter`. – Peter Wood Nov 04 '15 at 11:53

2 Answers2

1

I researched the History of Python blog written by Python's creator and they only ever seem to refer to it as a colon. Example reference: http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html

wjandrea
  • 28,235
  • 9
  • 60
  • 81
agentred5
  • 61
  • 8
  • 1
    That page doesn't talk about slicing though, it's a different usage of the colon. Is there another page that talks about the slice syntax? I couldn't find one from a quick search. – wjandrea Aug 04 '22 at 05:19
-1

Delimiter, I hereby name you : colonic slice

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Mr Mystery Guest
  • 1,464
  • 1
  • 18
  • 47