Skip to main content

A tiny library that simplifies class initialization from TOML files

Project description

TOMLini

A minimal, unintrusive library that allows you to add the ability to initialize an object from a TOML file without having to go through the dictionary dance.

Example

All you need to do is create your class with the @toml_init decorator:

# myclass.py

@toml_init
class MyClass:
    def __init__(v1, v2):
        self.v1 = v1
        self.v2 = v2

Define your TOML file (make sure the TOML key names match the __init__ parameter names!):

# file.toml

v1 = "aaa"
v2 = 1

And you're off to the races!

from myclass import MyClass

my_class = MyClass.load_from_toml("/path/to/file.toml")

print(my_class.v1, my_class.v2)

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

tomlini-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

tomlini-1.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file tomlini-1.0.0.tar.gz.

File metadata

  • Download URL: tomlini-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc1

File hashes

Hashes for tomlini-1.0.0.tar.gz
Algorithm Hash digest
SHA256 45d5016f147d30386b820d9df75fe0809b9d7673ae25394ce090adedd732d0ed
MD5 1707bced81e5e93bf867e768b5bac131
BLAKE2b-256 b2cea64afb35c5355651cc781f2ef4c1fee1d0ea3c1add40ba695db89936bf9b

See more details on using hashes here.

File details

Details for the file tomlini-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tomlini-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc1

File hashes

Hashes for tomlini-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edf62c89abf29883cb41d834d92841b50735adadaa19aa1c8fe0b47b1845cc25
MD5 2294e637e8530bdd5a09e86c43ed28b2
BLAKE2b-256 b7f4324bc797b6f8a4aeb61f2ebb375922ac6064c6437c6aa370bfd2efda58f7

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