ID EN
Typing

NewType

Python 3.11 🇮🇩 Bahasa Indonesia

Kelas pembantu untuk membuat tipe berbeda dengan overhead rendah.

Syntax

PYTHON
class typing.NewType(name, tp)

Contoh

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