List of dict in Python
Posted
by plalex
on Stack Overflow
See other posts from Stack Overflow
or by plalex
Published on 2010-03-24T14:36:08Z
Indexed on
2010/03/24
14:43 UTC
Read the original article
Hit count: 568
Hi everybody,
I've got a list of dict in Python:
dico_cfg = {'name': entry_name, 'ip': entry_ip, 'vendor': combo_vendor, 'stream': combo_stream}
self.list_cfg.append(dico_cfg)
I append to my list a lot of dict in the same way.
Now I would like to delete one dict and only one dict in this list? What is the best way to proceed?
I've try with the index of the list, but when I remove a dict from the list, the index is modify, so after some random remove my index doesn't correspond anymore to the dict I want to remove in my list. I hope that is clear. Maybe I can add an "id" row in my dict, so I can ask to remove more preciously the dict I want. I'll ask to remove the dict where id is equal to the id's dict I want to remove. How can I do that?
I hope I'm enough clear. Sorry but I'm a newbie in Python.
© Stack Overflow or respective owner