I don't seem to understand the correct concepts of factory.
Can someone help me write a simple test? I read some texts over the Internet and could not encode it the same way. Actually, I cannot understand this process. Copying the code is very simple, but I need to find out why this is not working.
class Factory:
def __init__(self):
self.msg = "teste"
def fabricateAnotherObject(self,obj,**kwargs):
return apply(obj,**kwargs)
class testClass:
def __init__(self,nome,salario,endereco):
self.nome = nome
self.salario = salario
self.endereco = endereco
def __str__(self):
return "Nome: " + str(self.nome) + "\nEndereco: " + str(self.endereco) + "\nSalario: " + str(self.salario)
a = Factory()
emp = a.fabricateAnotherObject(testClass,"George",2000,"Three Four Five Avenue")
print str(emp)
source
share