Skip to main content

Namedtuple with Strict Type Checking

Project description


Namedtuple with Strict Type Checking


pip install typedtuples


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.7.tar.gz (2.5 kB view hashes)

Uploaded source

Built Distribution

Typedtuples-1.0.7-py3-none-any.whl (2.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page