Python Glossary Русский

all Python 3Data typesterm

Ellipsis ...

special

The special singleton Ellipsis (written as the literal ...). Used as a placeholder body of a function or class, in type annotations (Callable[..., int]) and in NumPy for multi-dimensional slices.

Syntax

...  Ellipsis  type(...) -> ellipsis

... is a real singleton object (compare it with is), not a no-op: pass is a statement, whereas ... is an expression that evaluates to the Ellipsis object. It's handy as a unique sentinel when None is itself a valid value and can't stand for "nothing passed".

Examples

print(...)                # → Ellipsis
print(... is Ellipsis)    # → True
def stub(): ...           # заглушка тела вместо pass
print(type(...))          # → <class 'ellipsis'>
x = ...; print(x == Ellipsis)  # → True
print(bool(...))          # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy