Skip to main content

Python-based configuration reader

Project description

Python-based configuration reader

Simply enough, loads a file into a Python module object but does not place it in the module cache or otherwise bind it.

>>> import posixpath
>>> conf = load(posixpath.__file__)
>>> conf  # doctest: +ELLIPSIS
<module '<config>' from '...'>
>>> conf.pathsep
':'

And so on. You could also use load_dict to get a dict instead:

>>> type(load_dict(posixpath.__file__))
<type 'dict'>

Though, if you try to load files that aren’t recognized or loadable, you get an error:

>>> load("lala.ini")
Traceback (most recent call last):
  ...
ConfigurationError: no suitable loader for config module 'lala.ini'

Project details


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