In python, I'm trying to come up with a good way to add a variable that dynamically replicates the primary object every time it encounters a Variable class as one of the inputs. So if the variable class has 2 different input values, it will create 2 objects. For example:
objects = Object(arg1=10, arg2=Variable([10, 20]))
output:
objects = [Object(arg1=10, arg2=10), Object(arg1=10, arg2=20)]
The tricky part is that the Variable class could be any input for any sub-object, too. For example
objects = Object(subobject1=Subobject(arg1=Variable([10, 20]))
output:
objects = [Object(subobject1=Subobject(arg1=10)), Object(subobject1=Subobject(arg1=20))]
This is for a Blockly project, which is a visual programming language that generates python code from blocks. In that format, its sometimes more natural to use a variable as an input instead of wrapping all of the code in a loop. That's the reason why I'm trying to awkwardly inject a variable into the middle of a section of code instead of just doing a loop.