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.1.tar.gz
(2.2 kB
view hashes)
Built Distribution
Close
Hashes for Typedtuples-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c081875ad773f475df70c3a520d99fbbbd7ab5b02319499dc781f03e968f6a9 |
|
MD5 | dd97250a7459ba3f3fc6ead055c0cc0d |
|
BLAKE2b-256 | cbd20d6f608a57e4b4b58d0f6ccce8ddfb5eccf871f7fb6d15679ea44be31478 |