[Tutor] how to create alternative databases?

Alfred Milgrom fredm@smartypantsco.com
Sun Nov 3 23:27:02 2002


Hi:
I'm hoping someone can help me on how to create a large set of alternative 
databases.
I have a set of variables and lists that I want to select randomly.

The following code seems to work:
1. Create a file with all the different data in it, in the form of lists:
	...
	data[27] = ['a=[1,1,1]' , 'b=[2,2,2]' , 'etc="more data ..."']
	data[28] = ['a=[2,3,4]' , 'b=[3,4,5]' , 'etc="different data ..."']
	...

2. Then in the main program:

	import data
	...
	for i in data.data[27] :
	    exec(i)
	print a, etc
	...
As I said, this seems to work, but it feels very heavy-handed to me to have 
to use the exec() function in this way.

Is there a better way of doing this? (there are too many database sets to 
use "if ... elif ... etc.")
Thanks in advance,
Fred Milgrom