I'm wondering if there is a way to use an argument list for class initialization in Python.
For example in this class:
class TestClass:
def __init__(self, a, b, c):
self.result = a + b + c
t = TestClass(1, 2, 3)
print(t.result)
# 6
I use arguments a, b, c. If I have those arguments stored in list l = [1, 2, 3]
, can I somehow apply TestClass()
constructor to this list?
I'm looking for something similar as an apply
function in Common Lisp, that would work with Python class constructors.