Gerard flanagan:

> data.sort()
> datadict = \
> dict((k, len(list(g))) for k,g in groupby(data, lambda s:
>      '.'.join(s.split('.',2)[:2])))

That code may run correctly, but it's quite unreadable, while good
Python programmers value high readability. So the right thing to do is
to split that line into parts, giving meaningful names, and maybe even
add comments.

len(list(g))) looks like a good job for my little leniter() function
(or better just an extension to the semantics of len) that time ago
some people here have judged as useless, while I use it often in both
Python and D ;-)

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to