Skip to main content

A convinient .ini file to NamedTuple parser that supports type hinting

Project description

Convert a .ini config file to a typed Object

/videos/best_now.gif

Installation

Install via pip pip install config-to-object.
There are no dependencies.

Usage

Create your .ini configuration file. For an example look at example_config.ini. You can use any type of native python object such as tuples, lists, strings, floats, integers as parameter values (except dict). There type will be automatically recognized when loading the config file.

Load your configuration file using from config_to_object import load_config and config = load_config("path/to/your/config.ini")

You can access the values from your .ini using . syntax: words = config.Params.words.

If you want your config object to be type hinted, so that your IDE can give you better code completions, run ini_typefile path/to/your/config.ini config_types.py. Then, in your code add from config_types import Config and initialize your config with config:Config = load_config("path/to/your/config.ini")

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

config-to-object-1.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

config_to_object-1.0.1-py3-none-any.whl (3.5 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