Skip to main content

A simple struct-like object for Python

Project description

https://travis-ci.org/Nurdok/basicstruct.svg https://coveralls.io/repos/Nurdok/basicstruct/badge.svg?branch=master&service=github

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

Installation

pip install basicstruct

Usage

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.

Source Distribution

basicstruct-1.0.3.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file basicstruct-1.0.3.tar.gz.

File metadata

File hashes

Hashes for basicstruct-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7d394a95da8d8e7aedea40ce5158b863770a3f304533a3986b28bdc604873458
MD5 22e6e113bc6b05bc1dce1491f0593111
BLAKE2b-256 9c0298d511452a752895f1d77495911d2b957dbb5c5c87b37db26371c88348ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page