Python: deleting/removing class instances with none unique names -


for bit of context, looking create class called peasant game making in python. these workers have many attributes. created name , given id. since names have chance not unique id called delete class. think going instantiation wrong should id creating them unigue id giving them name?

class peasant:     peasantcount = 0      def __init__(self, name):         ...         peasant.id += 1         self.id = peasant.id         peasant.peasantcount += 1      def died(self, hp):         if hp <= 0:         peasant.peasantcount -=1         del self 

the def died method kill peasants if can make work, instance not deleted when instance.died(0) called.


Comments

Popular posts from this blog

What Are The Best Universities In The World?

Hard vs. Soft Water: What's The Difference?

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -