I have a function that takes two lists. Now what I have right now is that the function will take all of the parameters from the list and print them in a new row. The problem is that I can’t change the function itself but instead I would have to create a wrapper over it or a loop to do what I need it to do.
Name = ['one', 'two', 'three']
size = [1, 2, 3]
def createSomething(Name, size = None):
if size:
something = loudEchoCmd("something create --size %s --name %s " % ((',')join(size), (',')join(Name)))
else:
something = loudEchoCmd("something create --name %s " % (',')join(Name))
return something
What I get when I run this is:
Example:
something create --size 1, 2, 3 --name one, two, three
This is what I want to get:
Example:
something create --size 1 --name one
something create --size 2 --name two
something create --size 3 --name three
So I need to create a wrapper over that function that does what I need it to do. I have no idea how to do this. This is how I would get it to do by just changing the function:
def createSomething(Name, size = None):
if size:
for(i, (x1, x2)) in enumerate(zip(size,Name)):
loudEchoCMD("something create --size {0} --name {1}")
else:
for x in Name:
loudEchoCMD("something create --name {0}".format(x))
But no idea how to do it without changing the function 🙁
This should do what you want: