On 4/13/2012 22:33, Evan Driscoll wrote:
> d = {}
> def appender(e):
> d.get(f(e), []).append(e)
> map(appender, l)Just in case it isn't clear, the above has at least two problems and won't even come close to working. :-) Though I might as well ask another question... if I have a dict with values which are lists, what's a good way to say "append x to the list at key k, creating a list if it's not there"? dict.setdefault seems potentially promising but the docs are crappy and don't say how it works. Evan
signature.asc
Description: OpenPGP digital signature
-- http://mail.python.org/mailman/listinfo/python-list
