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
4
votes
2 answers

Dragon book compiler input

I'm executing the "Dragon book" front-end compiler, which expects a file input using java main.Main < fileInput.txt My question is: when I run args.length, the returned value is 0. Isn't fileInput.txt considered an argument? How could I catch it on…
user4259472
4
votes
2 answers

Tag values as warning or critical

I have a dictionary as follows (dict is named channel_info): {'flume02': u'98.94420000000001', 'flume03': u'32.562999999999995', 'flume01': u'2.15'} Im trying to loop through the dictionary and report back the values a warning or critical. I have…
letsc
  • 2,515
  • 5
  • 35
  • 54
4
votes
2 answers

Is using the args syntax in Python multiprocessing always necessary?

I am learning up on methods of multiprocessing in Python and have found myself with a question. Consider the following example: import multiprocessing as mp def worker(n): print('worker %d' % n) return if __name__ == '__main__': jobs =…
pretzlstyle
  • 2,774
  • 5
  • 23
  • 40
4
votes
1 answer

lambda expression with *args

I know that when we use *args, it means we are not sure how many arguments the function is going to receive. However, Python finally binds them together in a single tuple: >>> def f(*args): return type(args) >>> f(3,4,4,5)
Omid
  • 2,617
  • 4
  • 28
  • 43
4
votes
1 answer

Open a shell script in Terminal (Mac) no matter what the default application for bash scripts is set to

I wrote a shell script that I'm distributing to my friends. On my computer, it works great, because I set the default application for shell scripts to be Terminal. However, when my friends open it, the script opens in TextEdit. Is there a way to add…
Active Citizen
  • 119
  • 3
  • 12
4
votes
3 answers

How to use *args in a function to return a list of dictionaries?

Is it possible to use *args to produce a list of dictionaries where each dictionary has the exact same key and each value is the arg? For example, I currently have this function: def Func(word1,word2): return [{'This is a word':word1},{'This is…
Chris
  • 5,444
  • 16
  • 63
  • 119
4
votes
2 answers

How to use *args in a python class?

I am trying to get some args working in a class, I already got it running in a function from How to use *args in a function?. I'm trying to get that function into a class but I don't seem to understand how to initialize that class which has an init…
vimal
  • 393
  • 1
  • 3
  • 11
4
votes
4 answers

Passing filepath into Main(string[] args) not working

I am trying to pass a file path into a C# Console Application but am having problems with the string being incorrect by the time it reaches the console application. If I run my application from the command line, with a file path parameter: MyApp…
DevDave
  • 6,700
  • 12
  • 65
  • 99
4
votes
1 answer

Maven exec plugin - user args from console after hardcoded args

I'm implementing a simple RMI server and client. I wanted to speed up the tedious task of adding server codebase each time (lots of terminal-bloating text), so I decided to use the maven exec plugin. Here's how a part of my pom.xml looks…
Wojtek
  • 2,514
  • 5
  • 26
  • 31
4
votes
2 answers

Is there a "pythonic" approach to required properties (OOP)?

I'm struggling to find a "pythonic" approach to the following class organization: I have a base class with properties initialized in its constructor, for example: class Animal(object): def __init__(self, class_, species, is_domesticated): …
MitchellSalad
  • 4,171
  • 8
  • 23
  • 24
4
votes
3 answers

C# string handling how get path and args from a string

I have a string with quotes around the path as follows: "C:\Program Files (x86)\Windows Media Player\wmplayer.exe" arg1 arg2 If I use Text.Split(new Char[] { ' ' }, 2); then I get the first space. How to get the path and args ?
Kaya
  • 515
  • 2
  • 7
  • 19
3
votes
3 answers

Java: Printing out all the integers in args array

How do I print out a set of integers from my args variable in Java? I tried: System.out.println("The numbers are " + args.length); But all that does is print out the number of elements in the array. I want it so that if there are 5 arguments…
syncoroll
  • 137
  • 2
  • 3
  • 10
3
votes
1 answer

C# args without a main method?

I am new to the C# world but have seen other programming languages give access to command-line arguments from places like main function/method, sys.argv, etc. It was unusual to see the following statement placed globally in the boilerplate ASP.NET…
Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
3
votes
3 answers

I want a function to be able to take as an argument both a list of strings or several strings as *args

I have a function that should be able to take either many string arguments as *args, or a list of strings as an argument. For example: def getStuff(*stuff): for thing in stuff: print(thing) getStuff("cat", "mouse", "dog") getStuff(animals) I…
dm0413
  • 43
  • 4
3
votes
0 answers

dart arg parser implement default sub command

I'm using the dart args package with a set of subcommands. The command line syntax that I'm trying to implement is: dswitch beta switch dswitch beta install dswitch beta upgrade 'beta' is the command and there are three subcommands. what I want to…
Brett Sutton
  • 3,900
  • 2
  • 28
  • 53