List to dict conversion
Emile van Sebille
emile at fenx.com
Fri Oct 3 11:23:09 EDT 2003
"Wujek" <wujek at wujek.com> wrote in message
news:bljerg$ogd$1 at atlantis.news.tpi.pl...
> Hi!
>
> From list:
> >>> l
> ['key1:val1', 'key2:val2']
>
> I want dict:
> >>> d
> {'key2': 'val2', 'key1': 'val1'}
>
Guessing that this may have been read from a file, you may also be
interested in looking at ConfigParser. From the module:
DESCRIPTION
A setup file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.
--
Emile van Sebille
emile at fenx.com
More information about the Python-list
mailing list