I've got an object that maintains a dictionary. It has a "get_or_create" method that accepts a string as a key. It then looks up the key in the dictionary and either returns a 'Store' object if it finds a match or creates one and returns that.
The idea is that I can request a Store object by passing a key and if it already exists I get that or it will simply create me a blank object.
The code for the StoreContainer looks like this:
if key not in self.stores():
self.stores[sc] = Store()
self.stores[sc].id = key
Note: I don't have the exact code here so the indentation is approximate.
It seems to create all the stores fine but when I then add items to the stores, all the store items get it. I'm wondering if I'm just doing something obviously wrong - but I'm not sure what...