Posted By

cthulhupunk0 on 06/08/09


Tagged

dictionary aggregator


Versions (?)

Aggregator class for a dictionary of individual items


 / Published in: Python
 

  1. class itemDict:
  2. """
  3. ********************************************
  4. *Description : Aggregator for items
  5. *******************************************
  6. """
  7.  
  8. def __init__(self, init_items = {}):
  9. """
  10. ********************************************
  11. * Description : constructor. Optionally initializes
  12. * the item dictionary
  13. *******************************************
  14. """
  15.  
  16. self.items = init_items
  17. self.dictConf()
  18. def dictConf(self):
  19. """
  20. ********************************************
  21. *Description : Generic post-constructor function
  22. *******************************************
  23. """
  24. pass
  25.  
  26. def add_item(self, item):
  27. """
  28. ********************************************
  29. *Description : adds an item to the dictionary
  30. * or reassigns an item already present
  31. *******************************************
  32. """
  33.  
  34. self.items[item["public_name"]] = item
  35.  
  36. def del_item(self, name):
  37. """
  38. ********************************************
  39. *Description : deletes an item from the dictionary
  40. *******************************************
  41. """
  42.  
  43. del self.items[name]

Report this snippet  

You need to login to post a comment.