What is the term for a colon before a suite in Python syntax?

93 Views Asked by At

I want to know what the technical term for a colon in the context of introducing a suite after a statement is called. I do not mean colons in slices, key-value pairs or type hints, but this kind of usage:

if True:
    pass
else:
    pass

try:
    raise
except:
    pass

def foo():
    pass

lambda: ...  # I don't know if this is appertaining

I did not really find a fitting term online. Most only call them colons, while expecting the reader to understand the meaning of a colon in this context in Python. I found this website which uses the term "colon operator", but that doesn't feel right to me - especially as it lumps together all uses of colons under that umbrella term. I apologise if I have missed an obvious answer somewhere.

1

There are 1 best solutions below

0
ti7 On BEST ANSWER

It's simply called a "colon" :, but I might say and the grammar spec suggests you'd say something like "the start of a block"

https://docs.python.org/3/reference/grammar.html

# COMPOUND STATEMENTS
# ===================

# Common elements
# ---------------

block:
    | NEWLINE INDENT statements DEDENT 
    | simple_stmts