I have a class whose existence - or not - depends on the correctness of some input parameters.
QUESTION:
Would it be ok to create that factory function as a static member of the class I want an instance of? Is that the best way?
I initially tried to do it inside the __new__
operator but people said I should use factory function.
class MyClass:
@staticmethod
def GetAMy(arg):
if arg == 5:
return None
else:
return MyClass(arg)