Namedtuple with Strict Type Checking
Project description
TypedTuples
Namedtuple with Strict Type Checking
Download
pip install typedtuples
Examples
from typedtuples import *
Point1 = TypedTuple.of('Point', {'x': float, 'y': float})
class Point2(TypedTuple):
x: float
y: float
def __add__(self, other):
return Point2(self.x+other.x, self.y+other.y)
@TypedTuple.apply({'x': int, 'y': int})
class IntPoint:
def __add__(self, other):
return IntPoint(self.x+other.x, self.y+other.y)
print(Point1(x=2.5, y=5.3))
print(Point2(1.1, 3.2) + Point2(2.4, 5.5))
print(IntPoint(x=1, y=3) + IntPoint(5, 2))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Typedtuples-1.0.4.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for Typedtuples-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73ffcdd57f8b98308e86b794f8378bac0349bdfe7807bf1742fadf56d2eb4b0e |
|
MD5 | 896227a5846b4cb2d1538abbbfd7d3a1 |
|
BLAKE2b-256 | 873d854e67bb6928d5f6187ca2bc4b99715f2dc725bd954863d7a1547b8fc950 |