Skip to main content

Enjoy the flexibility of structs with esu!

Project description

Welcome to Esu Struct!

Build Status Documentation Status PyPI PyPI - Python Version PyPI - License

Enjoy the flexibility of structs with esu!

You can create types on the fly with previously declared fields and methods by using esu struct.
The created type additionally contains methods for equation, hashing and string representation.

Install

pip install esu

Usage

Struct

from esu import Struct, OpenStruct

Customer = Struct(
            'Customer', 
            'name', 'age', 
            methods={
                'greeting': lambda self: "Hello {}".format(self.__dict__['name'])
            })

dave = Customer()
dave.name = 'Dave'
dave.age = 25
dave.greeting() # => Hello Dave 

anna = Customer('Anna', 28)
anna.greeting() # => Hello Anna

OpenStruct

bob = OpenStruct()
bob.name = Bob
bob.age = 54
print(bob) # => [name=Bob, age=54]

su = OpenStruct({'name': 'Su', 'gender': 'female'})
su.employed = True
print(su) # => [name=Su, gender=female, employed=True]

Documentation

For further information, read the documentation that can be found: https://esu.readthedocs.io

Contribution

  1. Fork it!
  2. Make your changes!
  3. Send a PR!

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

esu-3.0.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file esu-3.0.0.tar.gz.

File metadata

  • Download URL: esu-3.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for esu-3.0.0.tar.gz
Algorithm Hash digest
SHA256 b22960d745cdb63aa189155fc87ea30838aab619b86b1f7ae26807f0c6375f70
MD5 0921dbfb632dc39091f0cbe74e427d0c
BLAKE2b-256 37370ae715221582ddd3ed6af5850f7369b714940e765c6ebb500275ba863c3b

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