Skip to main content

Instance builder library for Python inspired by Lombok

Project description

Instance-Builder - Instance builder library for Python inspired by Lombok

Python Versions PyPI version CI

Installation

pip install instance-builder

Usage

Builder

@builder("id", "name", "age", "email")
class User:
    def __init__(self, id: int, name: str, age: int, email: str) -> None:
        self.id = id
        self.name = name
        self.age = age
        self.email = email

user = User.Builder().id(0).name("Shuntaro Shimizu").age(99).email("ut.s.shimizu@gmail.com").build()

Getter

@getter
class User:
    __id: int = 0
    __name: str = "Shuntaro Shimizu"

user = User()
user.get_id()  # 0
user.get_name()  # "Shuntaro Shimizu"

Setter

@setter
class User:
    __id: int = 0
    __name: str = "Shuntaro Shimizu"

user = User()
user.set_id(1)  # user._User__id == 1
user.set_name("New Name")  # user._User__name == "New Name"

© Copyright 2021 to Shuntaro Shimizu, under the MIT license

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

instance-builder-0.1.8.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

instance_builder-0.1.8-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

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