Re: Initializing defaults to module variables

2006-04-13 Thread Burton Samograd
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > since you know the name of the config file you're looking for, you can > simplify (and unweirdify) your code a bit by changing your config file to > look like this: > > # File: config.py > > # > # configuration defaults > > some_param

Re: Initializing defaults to module variables

2006-04-13 Thread Fredrik Lundh
Burton Samograd wrote: > A reply to my own question, but I thought I would share the answer. I > got it to work with the following code: > > import config > import sys > from posix import environ > sys.path.insert(0, environ["HOME"]+"/.program") > reload(config) > > I have a file in my working di

Re: Initializing defaults to module variables

2006-04-13 Thread Burton Samograd
Burton Samograd <[EMAIL PROTECTED]> writes: > Is there a way to create a module namespace and populate it > before sourcing the file? A reply to my own question, but I thought I would share the answer. I got it to work with the following code: import config import sys from posix

Re: Initializing defaults to module variables

2006-04-13 Thread Luke Plant
Burton Samograd wrote: > 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)? The Django web framework happens to do something

Re: Initializing defaults to module variables

2006-04-13 Thread Eric Deveaud
Burton Samograd wrote: > 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") > impor

Re: Initializing defaults to module variables

2006-04-12 Thread Kent Johnson
Burton Samograd wrote: > 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 confi

Initializing defaults to module variables

2006-04-12 Thread Burton Samograd
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 th