I have a function that returns two values:
def dbfunc:
# ...
return var1, var2
I have this class:
class MyClass:
foo = ...
bar = ...
I'd like to assign the result of dbfunc() to the MyClass instance I'm trying to create. I'd tried this:
my_object = MyClass(dbfunc()) # does not work because the return type is a tuple
I could do this:
res = dbfunc()
my_object = MyClass(foo=res[0], bar=res[1])
but I'm actually trying to do this in a middle of a comprehensive list so I can not make these kind of "pre-affectations". I have to do it in one time.
Thanks for help.