The code you have has very confusing naming conventions that seem confusing to me --- HealthPotion is not a class, it is an instance, but the name CamelCase assumes that it is a class in python.
To have multiple health potions using your potion class, simply do
health_potion_1 = Potion("Health Potion", ...) health_potion_2 = Potion("Health Potion", ...) foobar_potion_1 = Potion("Foobar Potion", ...)
Although this is a pretty bad style, you probably want to be able to easily create health and similar potions with the same properties and potions with different effects.
For this you must have
class HealthPotion(Potion): def __init__(self, name="Health Potion", effect=10): super(HealthPotion, self).__init__(name, "Restores %d points of health" % (effect, ), effect, 0, 0) def use(self, you): you.hp_current+=self.effect
If you want to have multiple items in your inventory, it would be easier to just have a list (or set or some collection) for your inventory and have multiple instances in the list, for example.
inventory = [HealthPotion(), HealthPotion()]
If you want to perform stacking, I still think that this is an inventory function and not an element (outside the item.stackable member), so I will have an Inventory class that handles collections of an object, the contents of a face, chest or store. a simple implementation would be a wrapper around
inventory = [(HealthPotion(), 2)]
where any identical elements are represented as a pair of elements and a sum
It is also quite easy to convert the first to the last if you have a stacks_with method:
def stack_size(item, inv): "The number of items that will stack with item in inv" return len([i for i in inv if item.stacks_with(i)]) def stacked_inventory(inv): # if there is no stackable pair in the first i items # (ie the stack size for that item is 0 in inv[0:i]), # then the 'i'th item is a new stack, # with stack_size(inv[i], inv) items in it stacks = [ (inv[i], stack_size(inv[i])) for i in range(0,len(inv)) if not stack_size(inv[i], inv[0:i])] return stacks