Skip to content

risteon/schalter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

schalter

Build Status

The main feature of this package is to provide a decorator that records keyword-only function arguments into a configuration and allows to re-instantiate the values later (e.g. from a configuration file). See this MWE:

from schalter import Schalter


@Schalter.configure
def decorate_cake(cake, *, glaze="butter_cream", number_of_sprinkes: int = 10):
    cake.glaze(glaze)
    cake.sprinkle(number_of_sprinkes)


print("Glaze:", Schalter["glaze"])
print("Sprinkles:", Schalter["number_of_sprinkes"])

This outputs:

Glaze: butter_cream
Sprinkles: 10

You can also track an individual keyword-only argument under another configuration key:

from schalter import Schalter

Schalter["user_name"] = "James"


@Schalter.configure(name="user_name")
def print_msg(*, name):
    print("Hello {}".format(name))


print_msg()

Output:

Hello James

About

@Schalter.configure - Configuration management in Python for lazy people.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages