Newbie: splitting dictionary definition across two .py files

kar1107 at gmail.com kar1107 at gmail.com
Thu Mar 30 19:50:51 EST 2006


Hi,
I'm fairly new to python. I like to define a big dictionary in two
files and use it my main file, build.py

I want the definition to go into build_cfg.py and build_cfg_static.py.

build_cfg_static.py:
target_db = {}
target_db['foo'] = 'bar'

build_cfg.py
target_db['xyz'] = 'abc'

In build.py, I like to do
from build_cfg_static import *
from build_cfg import *

...now use target_db to access all elements. The problem looks like, I
can't
have the definition of target_db split across two files. I think they
reside in different name spaces? Is there any way I can have the same
dictionary definition split across two files?

The main reason is build_cfg_static.py is user generated and I want to
have build_cfg.py generated by a script. It helps to keep the two
dictionary entries separate.

Thanks,
Karthik




More information about the Python-list mailing list