Thoughts on language-level configuration support?

Aaron Brady castironpi at gmail.com
Wed Apr 1 02:09:28 EDT 2009


On Mar 30, 8:40 am, jfager <jfa... at gmail.com> wrote:
> I've written a short post on including support for configuration down
> at the language level, including a small preliminary half-functional
> example of what this might look like in Python, available athttp://jasonfager.com/?p=440.
>
> The basic idea is that a language could offer syntactic support for
> declaring configurable points in the program.  The language system
> would then offer an api to allow the end user to discover a programs
> configuration service, as well as a general api for providing
> configuration values.
>
> The included example implements the first bit and hints at the third,
> defining a function that looks up what variable its output will be
> assigned to and tries to find a corresponding value from a
> configuration source.  It's very preliminary, but I hope it gives a
> flavor of the general idea.
>
> Any thoughts or feedback would be greatly appreciated.

Hi, joining late.

I think you are talking about modifying a running program's code and
data from an external process.

My first guess at the closest Python can come is:

import shelve
configs= shelve.open( 'configs.dat' )

#stuff
for some computation:
    calc= Calc( )
    calc.precision= configs[ 'precision' ]
    calc.compute( )

All well and good if you can synchronize access to 'configs.dat', but
a subclass of shelve.DbfilenameShelf could accomplish that.

For background, "a shelf is a persistent, dictionary-like
object" (docs).  'configs.dat' would reside on disk, so any process
could access it.



More information about the Python-list mailing list