Questions tagged [multiple-arguments]

53 questions
0
votes
3 answers

How to use any item in a list as a split value in Python?

I want to do something to the effect of: x = [" ","cats"] def function(a): a.split([any of the elements in x]) return a How would I make Python accept any of the elements in x as an argument (so it splits as spaces and cats)? Edit: Sorry,…
V__M
  • 21
  • 4
0
votes
1 answer

Looping over files in a folder for shell script with multiple inputs

Specifying multiple inputs for command line tool? I am new to bash and am wanting to loop a command line program over a folder containing numerous files. The script takes two input files (in my case, these differ in one field of the file name…
Colin Anthony
  • 1,141
  • 12
  • 21
-1
votes
3 answers

TypeError while using *args in Python

I'm getting a TypeError while using a tuple in a multiple arguments function. Here's my code: def add(*args): result = 0 for x in args: result = result + x return result items = 5, 7, 4, 12 total = add(items) print(total) This…
v_ag
  • 278
  • 1
  • 5
  • 17
-1
votes
1 answer

How to run python script with multiple arguments in bash for loop?

I have a python script that I'd like to run in bash for loop in parallel. Python script takes multiple arguments as inputs via sys.argv[x]. For example, I'd like to run in bash for loop these lines: python py_script.py a b c & python py_script.py d…
Rok Petric
  • 75
  • 3
  • 9
-1
votes
2 answers

How to propagate an undefined number of template arguments?

Using the following class, I would like to be able to create an instance of a specified Foo() to store and call a function, but how can I transmit the necessary arguments to a function call ? template struct Foo { …
-2
votes
2 answers

Why my multithreading example takes the same amount of time as the none one?

I would like to create a few threads in my program where I pass multiple arguments. I found this example where it shows that you can avoid structs and pass multiple arguments to a thread. It worked. Or so I thought. When I looked at the duration of…
Gabriele
  • 737
  • 2
  • 8
  • 20
-2
votes
2 answers

Divide each element by the next one in python

How can i Divide each element by the next one in division function? i am passing arbitrary arguments in the calling function. Thanks in advance. def add(*number): numm = 0 for num in number: numm =num+numm …
yajant b
  • 396
  • 1
  • 4
  • 12
-2
votes
1 answer

Variable number of arguments in function

Is it possible to run a function like this: def call(a,*alphabets,*numbers): print(a) print(alphabets) print(numbers) I'm getting the following error: File "", line 1 def…
IndigoChild
  • 842
  • 3
  • 11
  • 29
1 2 3
4