__new__
does accept arguments and it can be used as a factory for other classes like your example attempts to do. From The standard type hierarchy
Classes are callable. These objects normally act as factories for new
instances of themselves, but variations are possible for class types
that override new(). The arguments of the call are passed to
new() and, in the typical case, to init() to initialize the new instance.
A working example is
class C:
def __init__(self, val):
self.what = "C"
print("i am C")
class D:
def __init__(self, val):
self.what = "D"
print("i am D")
class A():
def __new__(cls, config):
if config == "1":
return C(config)
elif config == "2":
return D(config)
foo = A("1")
print(foo.what, type(foo))
bar = A("2")
print(bar.what, type(bar))