ID EN
Typing

NewType

Python 3.11

Helper class to create low-overhead distinct types.

Syntax

PYTHON
class typing.NewType(name, tp)

Examples

Example 1
PYTHON
UserId = NewType('UserId', int)   Declare the NewType "UserId"
first_user = UserId(1)   "UserId" returns the argument unchanged at runtime

See Also

distinct types