More information about the Underscore mailing list

[_] Python Question

Matt Hamilton matth at netsight.co.uk
Fri Dec 18 10:04:27 GMT 2009

On 17 Dec 2009, at 23:57, Matthew Wilkes wrote:

> This is fun, here's another, less pretty one:
>
> attribute_data = mark.fetchall()
> keys = (v for k,v in attribute_data)
> attributes = dict((key, [k for k,v in attribute_data if v == key]) for
> key in keys)
>
> Alternatively, if you have something like Paste available you can use
> its MultiDict implementation:
>
> from paste.util.multidict import Multidict
> attribute_data = mark.fetchall()
> attributes = MultiDict(v[::-1] for v in  
> attribute_data).dict_of_lists()
>
> Anyone else want to play?  Come on Tim, you know you want to.

C'mon, Andy is finally coming over to learning a decent programming  
language and you are frightening him off!

-Matt

-- 
Matt Hamilton                                       matth at netsight.co.uk
Netsight Internet Solutions, Ltd.           Understand. Develop. Deliver
http://www.netsight.co.uk                             +44 (0)117 9090901
Web Design | Zope/Plone Development & Consulting | Co-location | Hosting