Hi, 

I'm writing an app that stores some user configuration variables in a
file ~/.program/config, which it then imports like so:

        import sys
        from posix import environ
        sys.path.append(environ["HOME"]+"/.program")
        import config

I can then access the configuration through code like:

        login(config.username)

My question is, how can I setup my program defaults so that they can
be overwritten by the configuration variables in the user file (and so
I don't have to scatter default values all over my code in try/catch
blocks)? Basically, I would like to be able to do something like this:

        config.login = "noone"
        config.password = "secret"
        .
        .
        .
        import sys
        from posix import environ
        sys.path.append(environ["HOME"]+"/.program")
        import config

So I guess the real question is:

        Is there a way to create a module namespace and populate it
        before sourcing the file?

-- 
burton samograd                                 kruhft .at. gmail
kruhft.blogspot.com     www.myspace.com/kruhft  metashell.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to