I have a function
def foo(a):
first_thing = 'first' + a
second_foo = 'second' + a + 'bar'
return first_thing, second_foo
which returns tuples. How can I achieve something like
class Thing(object):
def __init__(self, a):
first_thing, second_foo = foo(a)
self.first_thing = first_thing
self.second_foo = second_foo
in a nicer and more automated fashion?
I experimented with:
def __init__(self, a):
for key, value in foo(a):
setattr(self, key, value)
But can't unpack correctly.
self.first_thing, self.second_foo = foo(a)?