a clean way to define dictionary
aleax at aleax.it
Wed Jun 18 10:22:06 CEST 2003
> dict(zip(lst[0::2], map(eval, lst[1::2])))
Note: 2.3 only -- lists didn't support extended-slicing in Python 2.2.
> also, i don't think it's a good idea to use dict as a variable name since
> dict is a python type.
Very good advice! If you use dict as a local name, you shadow the
buit-in name 'dict' and therefore cannot any more call it e.g. in
order to generate a new dictionary, as above.
More information about the Python-list