[Tutor] Question on dictionary
Danny Yoo
dyoo at hashcollision.org
Fri Sep 12 18:04:12 CEST 2014
> i wrote a code like this
>
> for i in res:
> dict = {}
> dict['id_desc'] = str(i['id'])+','+str(i['description'])
> i.update(dict)
>
> is there any other simple methods to achieve this?
>
Can you avoid the intermediate "dict" and just assign to i['id_desc']
directly?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140912/35072a34/attachment.html>
More information about the Tutor
mailing list