Questions tagged [args]

Common abbreviation for "arguments", often used in reference to command-line arguments or function arguments.

A program can accept any number of arguments from the command line. This allows the user to specify configuration information when the program is launched.

The user enters command-line arguments when invoking the application and specifies them after the name of the command to be run.

898 questions
5
votes
6 answers

Can you have "ByRef" arguments in AS3 functions?

Any idea how to return multiple variables from a function in ActionScript 3? Anything like VB.NET where you can have the input argument's variable modified (ByRef arguments)? Sub do (ByRef inout As Integer) inout *= 5; End Sub Dim num As Integer…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
5
votes
2 answers

How to pass more than one record between two forms?

I want to pass more than one record between two forms. The user opens Form-A, selects multiple records and then clicks a button that opens Form-B. In Form-B there are two (or more) StringEdit controls and they should display values from the selected…
ulisses
  • 1,549
  • 3
  • 37
  • 85
5
votes
6 answers

args.length and command line arguments

I got confused with how to use args.length, I have coded something here: public static void main(String[] args) { int[] a = new int[args.length]; for (int i = 0; i < args.length; i++) { System.out.print(a[i]); } } The printout…
Wang Pei The Dancer
  • 171
  • 2
  • 5
  • 12
5
votes
5 answers

Optional parameters together with an array of parameters

I have a logging interface which I extend with some helpful extension methods as to make it possible for me to pass in a format and a list of arguments to avoid having to use string format every time a call the method. (it also help me follow FXCops…
Moriya
  • 7,750
  • 3
  • 35
  • 53
5
votes
3 answers

Bash - ack - limit length of matched line

Is there a way to limit the length of the line matched by ack? If ack matches, for example, a minified javascript file, the line it prints out can be very large. I still want it to show the highlighted match, but ideally with the line cut before and…
Andy Ray
  • 30,372
  • 14
  • 101
  • 138
4
votes
1 answer

How do I pass *args to my timeit.Timer object?

I originally made a custom function for timing functions that looks like this: def timefunc(function, *args): start = time.time() data = function(*args) end = time.time() time_taken = end - start print "Function:…
talloaktrees
  • 3,508
  • 6
  • 28
  • 43
4
votes
1 answer

How do you pass args to gmaven groovy:execute?

I need to pass in some args to a groovy script that is executed via the gmaven. I can do this no problem if I execute the script directly on the command line like so: printArgs.groovy... for (a in this.args) { println("Argument: " +…
Jay Shark
  • 635
  • 1
  • 11
  • 21
4
votes
1 answer

How to convert commandline "key=value" args to dictionary?

Currently I need to implement a python program that takes an arbitrary number of commandline arguments like python myprog.py x1=12 y3=hello zz=60 and the arguments need to be converted into a dictionary like {"x1": "12", "y3": "hello", "zz":…
hellopeach
  • 924
  • 8
  • 15
4
votes
2 answers

How can one pass an argument to docker run with spaces

This may be specific to the argument parsing done by https://github.com/atmoz/sftp/blob/master/entrypoint#L36 But I am trying to create a directory with spaces: Some examples I've tried: docker run -d atmoz/sftp:alpine-3.7 user:password:::Inbound…
David
  • 7,652
  • 21
  • 60
  • 98
4
votes
1 answer

How does an asterisk `*` work in the string formatting method `.format(*) ` in Python 3?

What is the use of * in .format(*)? When using it in the format function below print(new_string.format(*sum_string)) it changes the value of sum_string in the output from 18 to 1 Why does that happen? I have read the following link about *args and…
4
votes
6 answers

How transform String[] args with "=" split in java 8

I need to transform String[] args = {"--path=C:/log", "--time=hourly"}; into String[] args = {"--path", "C:/log", "--time", "hourly"}; How can I do this in Java 8, in an elegant way? List newArgs = Lists.newArrayList(); for (String s :…
Mister B
  • 123
  • 2
  • 15
4
votes
3 answers

passing a tuple in *args

I'd like to pass a tuple (or maybe a list) to a function as a sequence of values (arguments). The tuple should be then unpacked as an argument into *arg. For example, this is clear: def func(*args): for i in args: print "i = ",…
Kris
  • 67
  • 1
  • 1
  • 4
4
votes
2 answers

How to pass a bash array to awk properly

My goal is to create a script which lists top 5 the most memory consuming processes with their PIDs, Mem ifnos and Swap consumed. Partially, I have it done. But now, I would like to make it in one output in bash/awk. Awk doesn't see the passed bash…
Szymon Roziewski
  • 956
  • 2
  • 20
  • 36
4
votes
1 answer

PHP equivalent of Python's func(*[args])

In Python I can do this: def f(a, b, c): print a, b, c f(*[1, 2, 3]) How do you say this in PHP?
wes
  • 1,577
  • 1
  • 14
  • 32
4
votes
1 answer

When do I use **kwargs vs kwargs (*args vs args)?

I need to store both args & kwargs in a tuple for calling later, so in that case would the appropriate value in the tuple *args or args? In other words, will this work: def __init__(self, *args, **kwargs): self._buildCalls = [ …