Skip to main content

A simple struct-like object for Python

Project description

A simple struct-like object for Python. Compatible with Python 2.6+, 3.x, pypy and pypy3.


pip install basicstruct


To create your own struct, inherit from BasicStruct and define the field with the __slots__ class member. BasicStruct are efficient objects that are automatically comparable, hashable, picklable, printable and reprable.
from basicstruct import BasicStruct

class Point(BasicStruct):
    __slots__ = ('x', 'y')

p1 = Point(2, 3)
p2 = Point(1, y=6)
p3 = Point(x=0, y=0)

print(p1)  # prints: Point(x=2, y=3)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for basicstruct, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size basicstruct-1.0.3.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

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