On Fri, Sep 12, 2014 at 08:26:29PM +0530, Sunil Tech wrote:
> Hi All,
>
> i have a dictionary like
>
> res = [{'description': 'Testo', 'id': '676', 'parentOf': True},
>{'description': 'Pesto', 'id': '620', 'parentOf': False}]
That is not a dictionary. It is a list containing two dictiona
Thank you Danny and Joel :)
On Fri, Sep 12, 2014 at 9:51 PM, Joel Goldstick
wrote:
> On Fri, Sep 12, 2014 at 12:04 PM, Danny Yoo
> wrote:
> >
> >> i wrote a code like this
> >>
> >> for i in res:
> >> dict = {}
> >> dict['id_desc'] = str(i['id'])+','+str(i['description'])
>
> A minor re
On Fri, Sep 12, 2014 at 12:04 PM, Danny Yoo wrote:
>
>> i wrote a code like this
>>
>> for i in res:
>> dict = {}
>> dict['id_desc'] = str(i['id'])+','+str(i['description'])
A minor revision for the right side of above:
",".join(str(i['id'], str(i['description']))
>> i.update(dict
> 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?
Hi All,
i have a dictionary like
res = [{'description': 'Testo',
'id': '676',
'parentOf': True},
{'description': 'Pesto',
'id': '620',
'parentOf': False}]
i looking for the result like this
res = [{'description': 'Testo',
'id': '676',
'id_desc':'676_Testo',
'parentOf': True},
{'desc