Dictionary from list?

news_spam at md5.ca news_spam at md5.ca
Tue Oct 23 12:50:06 EDT 2001


Tim Peters <tim.one at home.com> wrote:
> It's quite handy in Perl!  Picture parsing a simple textual database with
> key + value lines (like, e.g., mail headers).  In Python you can use
> re.findall() to parse them all up in one gulp, but then you're left with a
> flat [k,v,...] list.  In Perl you assign the list to a hash, and you're
> done.  Now run this backwards:  since this is so convenient in Perl, Perl
> programs often create textual mini-databases in this format, and before you
> know it "Python sucks for everything I do" <wink>.  OTOH, in Python I often
> maintain textual mini-databases by writing repr(some_dict) to a file, then
> reconstruct the dict blazingly fast later via
> eval(open('that_file').read()) -- and before you know it Perl sucks for
> everything I do.

there's reason for that. Often you have to take third party text 
databases and modify them on daily basis. Perl is champion for quick and
dirty tasks. I am presently learning python and please with structure 
it gives my programs, but displeased with absence of richness of 
information flow. Its like going from bar to bar and pint glasses in new
bar are half the size of them in previous place. And price is same.(i 
realize pint is measuring so it is absurd - that how I feel). Perl is
irreplacable, but there are languages that I would before do it all in
perl now I see others. Like python.

> dictionary() is a constructor in 2.2, and I spent a lot of time worrying
> about what kind of arguments it should take.  I believe a flat [k,v,...]

Aha! thats perlism. I don't think guido wants to submit to the order of
perl.

regards as python newbie,
p.

-- 
Research causes cancer in rats.
110461387
http://gpg.md5.ca
http://perlpimp.com



More information about the Python-list mailing list