Using dictionaries

sorular sorular at netscape.net
Tue Dec 5 02:15:56 EST 2000


G'day

I am trying to write a python program where a "configuration.py" will
have all the user entered values in a dictionary format and a
"main.py" which will import these and use it as local parameters.

But, there are quite a few values in the dictionary 
ie
dict = { 'key1':'value1' , ' key2':'value2' , ......'keyN':'value2'}

and in the "main.py" these will be all renamed with the local names
ie
Val1 = dictionary.dict['key1']
Val2 = dictionary.dict['key2']
....
ValN = dictionary.dict['keyN']
	etc....

But overall, I still have a large numbe of values (ValN) to list... !

Q1- Is there a more efficient way to do this ? I thought about using a
for loop but that didnt work....

Q2 - would it be possible only to list the parameters in first file
(ie dictionary.py
	key1 = value1
	key2 = value2
	.....
	keyN = valueN
)
and inside main.py, do a simple import...
	import dictionary *
so that key1 can be used inside main.py as a local parameter?

thank

HK



More information about the Python-list mailing list