a clean way to define dictionary

Kendear kendear at nospam.com
Wed Jun 18 06:35:09 CEST 2003

i hope to define a dictionary this way:

lst = """
a    1
foo  3
bar  234
joe  321

lst = lst.split()

now lst refers to  ['a', '1', 'foo', '3', 'bar', '234', 'joe', '321']
i want to do something like

dict = {}
for key, value in lst:
     dict[key] = eval(value)

but key, value is not for taking 2
items at a time, but take a tuple
and unpacking it...

is there a way for the "for"
to take 2 items at a time?

or is there a more common way to define a dictionary
without all the punctuation marks?

More information about the Python-list mailing list