HELP: Creating dynmaic variable names

Frank Schwaak fs at sep.de
Thu Mar 6 03:25:07 EST 2003


Hi,

i need some help for creating dynamic variable names for lists.

Example:

i have the following text:

ENTRY = TestA
Position : 11
Info: Information A

ENTRY = TestB
Position: 12
Info: Information B

Now i want to get these into a list or hash named like this

hash1 = {ENTRY : 'TestA', Position : '11', Info : 'Information A'}
hash2 = {ENTRY : 'TestB', Position : '12', Info : 'Information B'}

So the aim is to create a new hash on the line between the two sections. The 
Problem is, that i don't know how many sections there are.

So, my thought was to do something like this

i = 0
for i = 1 to xx
   hash$i = .....
   i = i + 1

Is there a way to do this in Python?

Thanks, Frank




More information about the Python-list mailing list