Jan-07-2019, 01:08 PM
I am a Python newbie. I plucked some code from the internet and trying to build something that resemble the class I am supposed o build
Here is the code:
ConcreteProduct1 1
1
no product
{'_id': '1'}
which implies that either localid has changed value or that 1 == 1 means false!
What am I doing wrong?
Thank you
Here is the code:
def _factory_method(self, name = 'ConcreteProduct1'): # print (name, prodlist[name]) self.id = prodlist[name] localid = self.id print (localid) if localid == 1: print ("Created p1") return ConcreteProduct1() elif localid == 2: print ("Created p2") return ConcreteProduct2() else: print ("no product") print (vars(self)) @property def id(self): return self._id @id.setter def id(self, value): self._id = valueWhen I run it I get:
ConcreteProduct1 1
1
no product
{'_id': '1'}
which implies that either localid has changed value or that 1 == 1 means false!
What am I doing wrong?
Thank you