If you're using Python 3.6, it's a lot easier now. You can do: from typing import NamedTuple class Point(NamedTuple): x: float y: float = 0.0 and then Point(1.0).y == 0.0.
It's not actually; typing.NamedTuple is just a wrapper that calls the original collections.namedtuple. It does provide some additional features, like default values and methods.
If you're using Python 3.6, it's a lot easier now. You can do: from typing import NamedTuple class Point(NamedTuple): x: float y: float = 0.0 and then Point(1.0).y == 0.0.
It's not actually; typing.NamedTuple is just a wrapper that calls the original collections.namedtuple. It does provide some additional features, like default values and methods.