Sorry if I'm vague in my question, first time posting on stackoverflow. I think I'm overlooking something really basic here, gone over several tutorials on classes but cannot for the life of me figure out where I'm going wrong. My code is the following:-
class catalogue(object):
def __init__(self, catalogueitem):
self.catalogueitem = catalogueitem
self.colors = []
self.stock = "No Stock"
def setStock(self, stock):
if self.stock == "No Stock":
self.stock = stock
class shop(object):
def __init__(self, items):
self.shopItems = []
for item in items:
self.shopItems.append(catalogue(item))
def setStock(self, stock, item="purse"):
self.shopItems.catalogue(item).setStock(stock)
newshop = shop( ["purse","handbag","wallet", "clutchbag"] )
newshop.setStock(10, "handbag")
Basically what I'm trying to do is call the method inside the class catalogue, from within the class shop, and update the item with a new stock value of 10 within the instance newshop. I think I'm lacking a basic understanding of how to do this, and I think I've overlooked something very basic, can anyone help me figure it out please?
Thanks Betty