I'm assuming here that every string in your list_to_generate_expressions
is the name of an object that already exists. If that's the case, and your lists match up correctly, you can do this:
names = ['z_' + '_'.join([str(n) for n in name_nums]) for name_nums in list_to_generate_expression_names]
exprs = ['+'.join(expr_items) for expr_items in list_to_generate_expressions]
for name, expr in zip(names,exprs):
exec('{0} = {1}'.format(name,expr))
Note that this does use exec
, which should always be used cautiously, but since you're using your own lists it's perfectly safe.