I am not sure on the precise way to phrase the question as it is easier to just demonstrate with code. I would like to have a function that accepts a variable number of a set of 3 required and 1 optional arguments. As an illustration, _.each(items, function(item){
_.set(item, 'a', 4);
});
can accept any number of matplotlib.pyplot.plot()
set of variables. I would like to copy this behavior, but I am unsure of the proper way to do this using *args or similar. Below I illustrate the behavior I would like.
(x, y, color)
The only way I can think of is to loop through the arguments and perform a series of checks on make sure it satisfies the type for myFunc(name, lo, hi, step) # Do something
myFunc(name, lo, hi, step, name2, low2, hi2, step2) # Do something for name and name2
myFunc(name, lo, hi, name2, low2, hi2) # Same as above but use default step for both
and to check if (name, lo, hi, step)
is even given, but I would like to know if there is a more efficient way of doing this.
Edit:
I wanted the above behavior since my function uses the first set to identify a parameter and create a while loop. If any more sets of parameters remain it calls itself recursively to construct a nested while loop with the remaining parameters, etc. If no additional sets remain it will perform some data measurement and then return. This way I can loop through an arbitrarily large multi-dimensional space using a single recursive function.
答案 0 :(得分:0)
Is something like this what you're looking for?
options=" /pi=5 /m=AA"
test_id=root.findall('ProcessStart[@Options="%s"]' % options)[-1].get('Id')
If you don't want the tuple of items ordered, you would have to name each of the arguments and submit them named.