I have code snippts that can inspire you:
snippet1
class Model:
@classmethod
def instantiator(self, motor_generator):
# you can not put the yield here. it will transform this function into a generator.
return map(self, motor_generator) # map is lazy in python 3
snippet2
class Model:
@classmethod
def instantiator(self, motor_generator):
attrss = motor_generator # I put this outside because i fear a syntax misunderstanding with generators
return [self(attrs) for attrs in attrss] # with round brackets it would be evaluated on demand = in the for loop but not in this method
snippet3
for instance in Model.instantiator((yield motor_generator)):
instance.attr = 'asdf'