Skip to main content

No project description provided

Project description

structify

Rust like struct for python

Define a new struct:

from structify import struct, impl


@struct
class Point:
    x: float
    y: float

And add method implementation on that struct

@impl
def add(
    self: Point,
) -> float:
    return self.x + self.y

You can now instanciate the struct and call the method as if it was defined in the class:

p = Point(1, 2)

p.add()
>> 3

Limitation

  • Mypy and type checkers will not be aware of the method declared on your struct as they are added at runtime.
  • If you define methods on the same struct from different locations, you could end up having clash

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

struuuctify-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

struuuctify-0.0.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file struuuctify-0.0.1.tar.gz.

File metadata

  • Download URL: struuuctify-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for struuuctify-0.0.1.tar.gz
Algorithm Hash digest
SHA256 98a374398efbfda9b07b00b61f8cc6dfb9ab5aacd0f090b344fb1660301e81c0
MD5 2b2ca72b706cf84b8974241c0ecf46b2
BLAKE2b-256 711b2f1d9ad6a5b00db88f98a211635ff2faf1d1e8b10eabf9de0efb28ac6121

See more details on using hashes here.

File details

Details for the file struuuctify-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: struuuctify-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for struuuctify-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a7cf798f22bfd1e8668da83d1ce7017eec1485307f5e9647932f23296a77928
MD5 b6e688d0cd275fb9919ea98dab80d595
BLAKE2b-256 67191d07da72fd87f1867dc84f7265eb544aec5b408746ba38cec1b82625b716

See more details on using hashes here.

Supported by

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