optional-arguments Questions
3
Solved
Conventional way of dealing with optional list arguments is the following:
def func(list_of_vals = None):
if list_of_vals is None:
list_of_vals = []
...
I wounder if the following (shorter) v...
Climax asked 28/10, 2016 at 21:36
2
Solved
How to specify multiple optional arguments in a function without respecting the order they are given
The below example the optional arguments must be given in order; hence ShowHeaders Must Precede ValueAdd and so on. If I want to specify ValueAdd, I*must* specify ShowHeaders:
Function Example(Val...
Roundhead asked 26/8, 2013 at 22:36
7
Solved
How do you create a command with optional arguments in LaTeX?
Something like:
\newcommand{\sec}[2][]{
\section*{#1
\ifsecondargument
and #2
\fi}
}
}
Then, I can call it like
\sec{Hello}
%O...
Dentilingual asked 28/11, 2009 at 10:46
6
Solved
I want to write a function that calls both plot() and legend() and it would be ideal if the user could specify a number of additional arguments that are then passed through to either plot() or lege...
Hildegardehildesheim asked 8/11, 2010 at 14:49
23
Solved
I'm trying to convert a longish hollow "data" class into a named tuple. My class currently looks like this:
class Node(object):
def __init__(self, val, left=None, right=None):
self.val = val
se...
Buckthorn asked 5/7, 2012 at 19:16
9
Solved
How do I test if optional arguments are supplied or not? -- in VB6 / VBA
Function func (Optional ByRef arg As Variant = Nothing)
If arg Is Nothing Then <----- run-time error 424 "object requi...
Magpie asked 2/11, 2009 at 11:38
7
Solved
In fortran, we can define default arguments. However, if an optional argument is not present, it can also not be set. When using arguments as keyword arguments with default values, this leads to aw...
Mortie asked 9/6, 2016 at 10:55
11
Solved
Does C# 4.0 allow optional out or ref arguments?
Socialist asked 20/5, 2010 at 1:45
9
Solved
How to pass optional arguments to a method in C++ ?
Any code snippet...
Colliery asked 24/9, 2010 at 4:1
4
Solved
In C, getopt_long does not parse the optional arguments to command line parameters parameters.
When I run the program, the optional argument is not recognized like the example run below.
$ ./resp...
Argybargy asked 27/6, 2009 at 12:15
4
Solved
I want to test function calls with optional arguments.
Here is my code:
list_get()
list_get(key, "city", 0)
list_get(key, 'contact_no', 2, {}, policy)
list_get(key, "contact_no", 0)
list_get(key,...
Neutralization asked 7/3, 2016 at 13:16
3
Solved
The following code does not compile.
type A(?arg) =
member __.Arg : string option = arg
type B(?arg) =
inherit A(arg) //ERROR expected type string but has type 'a option
I assume this is beca...
Bequeath asked 17/8, 2011 at 15:41
1
Solved
I have a general question that I couldn't find a satisfactory answer for. I'm building a set of visualization functions, and I want to let the user have flexibility when using them. For example, I'...
Hurtle asked 14/1, 2021 at 15:42
3
Solved
As we know, optional arguments must be at the end of the arguments list, like below:
def func(arg1, arg2, ..., argN=default)
I saw some exceptions in the PyTorch package. For example, we can find t...
Chemulpo asked 9/9, 2020 at 9:38
2
Solved
For my code in Python, I would like to call many functions with a specific argument. However, for some functions, that argument does not do anything. Still, I would like to add the argument for com...
Iz asked 2/12, 2019 at 9:37
1
Solved
I need to change the global variable S at a.py from b.py, but it is used as a default value in a function at a.py.
a.py
S = "string"
def f(s=S):
print(s)
print(S)
b.py
import a
def...
Condenser asked 26/8, 2019 at 17:2
1
Solved
I'd like to modify an existing item in a map, as in replace the value of an existing key with a new one, with an added clause if the key does not exist in the Map already, to simply create a new ke...
Diffraction asked 15/7, 2019 at 9:43
2
Solved
I am new to Kotlin and I have an enum containing many values, those values refer to different states my application has.
Now I need to log something whenever the app enters a state but some state ...
Emalee asked 30/5, 2019 at 13:15
3
Solved
I would like to have the following syntax:
python utility.py file1 FILE1 file2 FILE2
where file1 and file2 are optional arguments.
It is simple to make it working with this syntax:
python utili...
Dinnage asked 3/7, 2012 at 12:10
3
Solved
I am new to TypeScript and have a little problem with an optional argument in a function. I got the following error in Visual Studio Code for the query argument (see screen shot). I really don't un...
Gulch asked 19/2, 2017 at 0:5
2
C# and F# has different implementation of the default (or optional) parameters.
In C# language when you add default value to the argument you'll not change its underlying type (I mean type of the ...
Platina asked 13/4, 2013 at 14:34
2
Solved
So I have a function with several optional arguments like so:
def func1(arg1, arg2, optarg1=None, optarg2=None, optarg3=None):
Optarg1 & optarg2 are usually used together and if these 2 args...
Lagging asked 7/4, 2017 at 13:20
3
Solved
I'm using Python.NET to load a C# Assembly to call C# code from Python. This works pretty cleanly, however I am having an issue calling a method that looks like this:
A method within Our.Namespace...
Grayce asked 4/11, 2014 at 18:54
1
Solved
In one comment to the accepted answer on how to "correctly" specify optional arguments in R, @LouisMaddox said
missing() is useless when you want to use proper checking of supplied parameters a...
Foreworn asked 25/12, 2016 at 20:47
2
Solved
Matlab includes many plotting functions which take an optional argument being the handle to the axis to plot to. There are many solutions online for adding optional arguments to user-defined functi...
Macnair asked 7/9, 2016 at 9:20
1 Next >
© 2022 - 2025 — McMap. All rights reserved.