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
14
votes
3 answers

python function *args and **kwargs with other specified keyword arguments

I have a Python class with a method which should accept arguments and keyword arguments this way class plot: def __init__(self, x, y): self.x = x self.y = y def set_axis(self, *args, xlabel="x", ylabel="y", **kwargs): …
fmonegaglia
  • 2,749
  • 2
  • 24
  • 34
12
votes
2 answers

accessing *args from within a function in Python

Hi everyone this is probably something extremely simple that i'm overlooking but can someone point me in the right direction for how to handle this problem. def nodeFunction(self,*args): return self[1] + self[2] Basically what I am trying…
SacredGeometry
  • 863
  • 4
  • 13
  • 24
12
votes
2 answers

Kubernetes pod/deployment while passing args to container?

I'm new to docker/k8s world... I was asked if I could deploy a container using args to modify the behavior (typically if the app is working in "master" or "slave" version), which I did. Maybe not the optimal solution but it works: This is a simple…
IsKor
  • 123
  • 1
  • 1
  • 4
12
votes
6 answers

java 101, how do I count the number of arguments passed into main?

For example public static void main(String[] args) { int count = 0; for (String s: args) { System.out.println(s); count++; } } is there some way of doing something like int count =…
user1464251
  • 333
  • 1
  • 2
  • 16
11
votes
3 answers

python: when can I unpack a generator?

How does it work under the hood? I don't understand the reason for the errors below: >>> def f(): ... yield 1,2 ... yield 3,4 ... >>> *f() File "", line 1 *f() ^ SyntaxError: invalid syntax >>> zip(*f()) [(1, 3), (2, 4)] >>>…
Rusty Rob
  • 16,489
  • 8
  • 100
  • 116
10
votes
0 answers

Do Python's `*` and `**` specifiers have a name?

Possible Duplicate: proper name for python * operator? * is clearly used when unpacking an arbitrary number of arguments and ** is used when unpacking keyword arguments as a dictionary. It is conventional to use *args and **kwargs, and I tend to…
johnsyweb
  • 136,902
  • 23
  • 188
  • 247
10
votes
2 answers

Segfault with strcmp

I am using strcmp in following ways Passing char[] array names Passing pointers to string literals but, the second result in seg fault. even though i have confirmed that pointers point to correct string literals, i am confused as to why i am…
Jimm
  • 8,165
  • 16
  • 69
  • 118
9
votes
3 answers

What does self do?

Possible Duplicate: Python 'self' keyword Forgive me if this is an incredibly noobish question, but I never did understand self in Python. What does it do? And when I see things like def example(self, args): return self.something what do…
user775171
9
votes
2 answers

Python error: the following arguments are required

I have the Python script that works well when executing it via command line. What I'm trying to do is to import this script to another python file and run it from there. The problem is that the initial script requires arguments. They are defined as…
9
votes
2 answers

Python 3.5 TypeError: got multiple values for argument

def f(a, b, *args): return (a, b, args) f(a=3, b=5) (3, 5, ()) whereas: f(a=3, b=5, *[1,2,3]) TypeError: got multiple values for argument 'b' Why it behaves like this? Any particular reason?
Jan Sikora
  • 91
  • 1
  • 1
  • 4
9
votes
1 answer

Escape dollar sign in command line arguments

When I pass in "$1000" through the command line and retrieve the string through args[0], it becomes "000". How can I maintain the full string in my java code?
John Fda
  • 317
  • 1
  • 4
  • 7
9
votes
1 answer

vim:what's the difference between buffers and args

I'm using vim,when I see the :args command ,I don't know the difference between args and buffers. in vim,I know buffers is important, so I thought :arg* is not important,maybe it's a "legacy command", but when I play the vim genius game ,I see…
Huhu
  • 121
  • 1
  • 5
8
votes
5 answers

is this overkill for assessing Main(string[] args)

I've got the following and was wondering if the initial test is overkill: static void Main(string[] args) { if (args.Length == 0 || args == null) { //do X } else { //do Y } } in other words what I'm…
whytheq
  • 34,466
  • 65
  • 172
  • 267
8
votes
1 answer

Why can't both args and keyword only arguments be mixed with *args and **kwargs simultaneously

The usage of *args and **kwargs in python is clear to me and there are many questions out there in SO (eg Use of *args and **kwargs and What does ** (double star/asterisk) and * (star/asterisk) do for parameters?). But one thing I would like to…
deponovo
  • 1,114
  • 7
  • 23
8
votes
1 answer

Python: Using *args, **kwargs in wrapper functions

I'm writing a wrapper function for Django's render_to_response() to add a CSRF processing. The logic is: def some_view (request) dictionary = {'context_param': some_param} dictionary.update(csrf(request)) # ... view code here return…
Alexander
  • 632
  • 2
  • 7
  • 19
1
2
3
59 60