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
-2
votes
1 answer

Is there a way to use *args, to dynamically take as many as inputs I want in a function?

def f(a, b,c,d): x = open('data.txt', 'r') for line in x: line = line[a:b] + ':' + line[c:d] + ':' x2 = open('data2.txt', 'a+') x2.writelines(line) f(0,2,2,6) I have raw data which is something like…
-2
votes
1 answer

Why i cant use static method from my main?

i'm making a diary program. In Diary class i made method called "addStudent" But i cant figure out why it is invisible in my main? EDIT i added code, sorry for just one block and not 3 but lombok imports are causing issues with formatting EDIT2 i…
santana011
  • 119
  • 10
-2
votes
5 answers

Accept args and put in a python list only even numbers

I have written the following Python code, but its throwing me an error def myfunc(*args): mylist = list() for num in args: if num%2 ==0: mylist = mylist.append(num) return mylist It throws…
Raghu
  • 1,141
  • 5
  • 20
  • 39
-2
votes
3 answers

How to use *args and self in Python constructor

I need a Python method to have access to self for instance variables and also be able to take any number of arguments. I basically want a method foo that can be called via foo(a, b, c) or foo() In the class, I think the constructor would be def…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
-2
votes
1 answer

if a website URL does not contain any language code then do something

ASP.Net C# newbie here. I am looking for suggestions upon constructing a condition to validate if a website URL do not contain any ISO language code or regional sub-directory e.g. /us-en, /ae-en, /gb-en, etc. using regular expression. Sample website…
-2
votes
1 answer

How to use conditional statements with argparse?

So I have created my argparse which has two different flags. One is -a and the other one is -b. When I run my script damage.py with a specific flag, I want it to be able to execute a function depending on what flag is passed. For example if I pass…
-2
votes
3 answers

Input one file through command line

public class TFIDF { public static void main (String args[]) { if (args.length < 2) { System.out.println("Use Two Files!"); } } Hi, I have this small section of code from a larger program which allows me to input txt…
Peter Toole
  • 93
  • 2
  • 9
-2
votes
5 answers

Python 3, *args, print the output in a list

def even_number(*args): for even in args: if even%2==0: even print(list(str(even)),end='') I want to print the output in a list as [8,6,4], but rather it prints it out as [8],[6],[4]. If I put out the last print…
YAsh rAj
  • 85
  • 1
  • 6
-2
votes
1 answer

Why do we need `*args` in decorator?

def pass_thru(func_to_decorate): def new_func(*args, **kwargs): #1 print("Function has been decorated. Congratulations.") # Do whatever else you want here return func_to_decorate(*args, **kwargs) #2 return…
Jin
  • 1,902
  • 3
  • 15
  • 26
-2
votes
2 answers

using *args and **kwargs as a substitute for function's arguments

I hava a question about *args and **kwargs. I know that they are used when you do not know how many arguments will be passed to function. But can it be a substitute for some arguments that are actually required when I do not know what those are? If…
McCzajnik
  • 163
  • 1
  • 12
-2
votes
2 answers

C++ Delete char**

I know there have been many questions about this but I have tried everything and NOTHING seems to be working. I have char** and when I try to delete it, I get exception thrown. When I do not delete it, an exception is thrown after the function…
Everyone
  • 1,751
  • 13
  • 36
-2
votes
2 answers

No-args constructor

So this situation is a bit frustrating for me because my online teacher prefers us to just learn the lessons online by ourselves independently and everywhere I have looked I still cannot find out how to use no-args completely The following is the…
zenon
  • 29
  • 2
-2
votes
1 answer

Python : how to pass *args into tuple google API

currently I am working with Google API for Python. I am using google Place Library as an input parameter for google Distance Matrix. This is what I have: Dest = google_places.nearby_search( location='Jakarta, Indonesia', keyword='Kantor, Office,…
dya
  • 195
  • 1
  • 2
  • 16
-2
votes
2 answers

Creating a tuple out of *args

I've tried, but I can't figure this out so far. I want to create a list of tuples, each one built out of dictionary values: my_list = [(x['field1'], x['field2']) for x in my_dict] But the issue is that I want to do this inside a function, passing…
-2
votes
2 answers

Python 3.X using multiple *args for different stuff

I know that *args are used when you dunno how many args are being used inside the function call. However, what do I do when I want one group of *args to do X and one group of *args to do y?