Questions tagged [multiple-arguments]
53 questions
140
votes
4 answers
Using the same option multiple times in Python's argparse
I'm trying to write a script that accepts multiple input sources and does something to each one. Something like this
./my_script.py \
-i input1_url input1_name input1_other_var \
-i input2_url input2_name input2_other_var \
-i input3_url…

John Allard
- 3,564
- 5
- 23
- 42
28
votes
3 answers
Passing a function with multiple arguments to DataFrame.apply
Suppose I have a dataframe like this:
df = pd.DataFrame([['foo', 'x'], ['bar', 'y']], columns=['A', 'B'])
A B
0 foo x
1 bar y
I know how to use a single argument function with Apply when it comes to dataframes, like…

Michael Henry
- 345
- 1
- 3
- 5
14
votes
3 answers
R: apply a function to every element of two variables respectively
I have a function with two variables x and y:
fun1 <- function(x,y) {
z <- x+y
return(z)
}
The function work fine by itself:
fun1(15,20)
But when I try to use it with two vectors for x and y with an apply function I do not get the correct…

adam.888
- 7,686
- 17
- 70
- 105
6
votes
3 answers
Lua return multiple values as arguments
I have a function (that I cannot change) returning multiple values :
function f1()
...
return a, b
end
and another function (that I cannot change) taking multiple arguments :
function f2(x, y, z)
...
end
is there a way to do :
f2(f1(),…

Antoine Richermoz
- 63
- 5
6
votes
1 answer
Iterating variadic template types
I've been stuck on this for a while and I ran out of ideas, help appreciated!
The following segments are example code, to simplify.
Assume the following:
class Base;
class DerivedA : public Base;
class DerivedB : public Base;
and this:
class…

RDGC
- 63
- 1
- 4
6
votes
1 answer
When to use explicit specifier for multi-argument constructors?
I have recently learned about the explicit specifier.
Suppose we have:
f( W, W, W );
Now if we do
f( 42, 3.14, "seven" );
The compiler will attempt the following implicit conversions:
f( W(42), W(3.14), W("seven") );
If we have defined matching…

P i
- 29,020
- 36
- 159
- 267
3
votes
2 answers
passing multiple arguments in python on a loop
I have a function that takes multiple arguments of tuples and process it accordingly. I was wondering if I can pass the arguments in a for-loop.
For example:
def func(*args):
for a in args:
print(f'first {a[0]} then {a[1]} last…

JediBig
- 51
- 1
- 4
2
votes
1 answer
Access 2 arguments in a function out of order?
Say I have a function that has (A, B, C, D, E) arguments.
Foo(A, B, C, D, E)
But I don't need them all the time. Sometimes I just need A and C for example. Right now I would have to call it like this:
Foo('beef', '', 'sour cream', '', '')
But those…

Kjata1013
- 35
- 6
2
votes
0 answers
Using qutip.mesolve() to calculate the time evolved Hamiltonian with time dependent variable
I'm trying to find the time evolution of some initial state with a time dependent hailtonian where also the z variable (gradient of time evolution) is time dependent. Usually the qutip.mesolve() function can be used for this when the z variable is a…

Calvin
- 21
- 1
2
votes
2 answers
minimize a function with multiple argument in Julia
I have a function which depends on a let say N input x=(x1,x2,x3,x4,...,xN) and I have a set of M possible vectors p = ( (p11,p12,p13,...,p1N),...,(pM1,pM2,...,pMN))
I would like to find the value of the minimum for which j in p[j] the minimum is…

raskolnikov
- 235
- 1
- 6
2
votes
3 answers
Excel multiple IF statements or macro's to solve this problem?
I'm trying to make multiple IF statements in Excel help my club convert event registrations into a template which can import into a scoring program.
The registration export places 3 attributes into a single cell. I need a way to separate those 3…

Dbaus
- 23
- 3
2
votes
2 answers
How to run on BASH a python script that takes multiple arguments using GNU parallel?
I have a python script which I normally execute from BASH shell like this:
pychimera $(which dockprep.py) -rec receptor1.pdb -lig ligand1.mol -cmethod gas -neut
As you see some of the arguments need an input (e.g. -rec) while others don't (e.g.…

tevang
- 518
- 1
- 4
- 17
2
votes
3 answers
adding together multiple sets of columns in r
I'm trying to add several sets of columns together.
Example df:
df <- data.frame(
key = 1:5,
ab0 = c(1,0,0,0,1),
ab1 = c(0,2,1,0,0),
ab5 = c(1,0,0,0,1),
bc0 = c(0,1,0,2,0),
bc1 = c(2,0,0,0,0),
bc5 = c(0,2,1,0,1),
df0 =…

Dennis C
- 23
- 4
2
votes
1 answer
Expand a function of an arbitrary number of arguments if it is linear in each argument
Is there a way to write a replacement rule for a function f with an arbitrary number of arguments that makes it linear in all its arguments?
An example for when f has three arguments:
f( x1+x4 , x2 , x3 ) = f(x4,x2,x3) + f(x1,x2,x3)
f( x1 , x2+x4 ,…

jjstankowicz
- 121
- 4
2
votes
2 answers
Multiple Inheritance and calling super()
I get the error:
TypeError: __init__() takes exactly 2 arguments (3 given)
When trying to instantiate an object from the class Top:
super(Middle1, self).__init__(name, "middle")
class Base(object):
def __init__(self, name, type):
…

Esser420
- 780
- 1
- 8
- 19