imagine the following scenario:
class A:
def __init__(self, arg1=3, arg2=5):
pass
def createA(arg1=None, arg2=None):
if arg1 is None:
if arg2 is None:
a = A()
else:
a = A(arg2=arg2)
else:
if arg2 is None:
a = A(arg1=arg1)
else:
a = A(arg1=arg1, arg2=arg2)
return a
Whats the best way to implement this behavior, with the followings in mind:
- I can't/don't want to change class
A - I don't want to explicitly add the default values of
A's constructor's parameters to thecreateAfunction?
For example is there any value that indicates a not passed optional argument? Something like:
if arg1 is None:
newArg1 = NotPassed
else:
newArg1 = arg1
if arg2 is None:
newArg2 = NotPassed
else:
newArg2 = arg2
A(arg1=newArg1, arg2=newArg2)