resolver

Resolve specially formated statements to Python objects.

About

Turn strings like "packagename.modulename:Eval().the_rest()" into whatever you would get back by performing a similar sequence of imports and calls. This is useful for config files and situations where you would like to import things in a lazy way. Later this package will probably provide a way to restrict resolution for safety.

Download

Download the latest release from resolver's Cheese Shop Page.

Blessed are the cheesemakers!

Quick and Dirty

Resolver statements look like this:


    dot.path.to.import:TheRest().is_evaled.('in', 'that', 'context')

The following two lines would be equivalent:


    x = resolve('foo.bar:baz')
    from foo.bar import baz as x

Everything to the right of the colon is evaled so:


    x = resolve("module:FooApp('blarg').prop")

...is like...


    from module import FooApp
    x = FooApp('blarg').prop

You can even do this:


    resolve("pak.mod:foo('resolve(\'pak.mod:bar\')')")

If you just want to eval an expression:


    plus_two = resolve(":lambda x: x + 2")

Questions, comments, suggestions, bugs... :