Samuel a écrit :
> Hi,
>
> is there a short version for this?
>
> res_dict = {}
> for resource in res_list:
> res_dict[resource.get_id()] = resource
>
> This does not work:
>
> res_dict = dict([r.get_id(), r for r in res_list])res_dict = dict((r.get_id(), r) for r in res_list) or if you have to be compatible with older python versions: res_dict = dict([(r.get_id(), r) for r in res_list]) HTH -- http://mail.python.org/mailman/listinfo/python-list
