Questions tagged [positional-parameter]
75 questions
189
votes
6 answers
What is the difference between named and positional parameters in Dart?
Dart supports both named optional parameters and positional optional parameters. What are the differences between the two?
Also, how can you tell if an optional parameter was actually specified?
![](../../users/profiles/123471.webp)
Seth Ladd
- 77,313
- 56
- 165
- 258
19
votes
3 answers
Assigning to a positional parameter
How can I assign a value to a positional parameter in Bash? I want to assign a value to a default parameter:
if [ -z "$4" ]; then
4=$3
fi
Indicating that 4 is not a command.
![](../../users/profiles/160829.webp)
Freeman
- 5,246
- 2
- 41
- 46
14
votes
1 answer
python SyntaxError: positional argument follows keyword argument
I have a python 3 function which is defined like below:
def hidden_markov_model(distribution, K=3, N=100, *args):
when i call the function, i get this error:
Q_hmm = hidden_markov_model(Gaussian, K=K, N=N,
mu,…
![](../../users/profiles/1658325.webp)
Atena
- 359
- 1
- 2
- 18
7
votes
1 answer
define Julia functions with optional positional arguments
From this link, it says:
# You can define functions with optional positional arguments
function defaults(a,b,x=5,y=6)
return "$a $b and $x $y"
end
defaults('h','g') # => "h g and 5 6"
defaults('h','g','j') # => "h g and j…
![](../../users/profiles/5205130.webp)
lanselibai
- 913
- 1
- 11
- 27
5
votes
2 answers
Using a loop's positional parameters inside an inner loop in Raku
Here is the code:
my @s=;
for @s.kv {
for ($^k ... @s.elems) {
printf("%s ", $^v);
}
printf("\n");
}
Expected output is:
# a b c d
# b c d
# c d
# d
But it gives this error (possibly among others)
key 0, val 1 Too few…
![](../../users/profiles/12212606.webp)
Lars Malmsteen
- 1,819
- 2
- 13
5
votes
1 answer
Positional Parameter error in powershell script
I was trying to install/update EPO agent through PowerShell, but I am getting below error.
I am new to PowerShell so I am not able to see what is causing this.
Below is the script I used to update the agent :
Start-Process -FilePath $scriptpath…
![](../../users/profiles/5585279.webp)
Gopi
- 537
- 2
- 8
- 24
3
votes
2 answers
python positional arguments
I am trying to understand how the parameters to this function are interpreted:
def f(a, *, b):
return a, b
It appears this function forces the caller to call f() with exactly 2 params and the second param should always be a named b= param. How…
![](../../users/profiles/2399453.webp)
user2399453
- 2,378
- 2
- 22
- 49
3
votes
3 answers
Python calling out positional argument
I have a python function (python 2.5) with a definition like:
def Foo(a, b='Silly', c='Walks', d='Spam', e='Eggs', f='Ni', *addl):
Where addl can be any number of strings (filenames) to do something with.
I'm fine with all of the defaults, but I…
![](../../users/profiles/6156113.webp)
MellowNello
- 53
- 5
2
votes
1 answer
How can I get argparse to recognize a positional argument which follows a variable length optional argument?
I am writing a script that will be used to merge several input files, generating a single output file, and I want to build a small command line interface using argparse. To me, the most natural-seeming way to do it would be to have a single…
![](../../users/profiles/3083138.webp)
stachyra
- 4,053
- 3
- 18
- 29
2
votes
1 answer
How does Gradle's CopySpec filter method signature relate to the example given?
I am trying to implement something that will replace ${pattern} in xml files in my build.gradle file:
processResources {
eachFile { FileCopyDetails fileCopyDetails ->
if (fileCopyDetails.name.contains("blueprint.xml")) {
…
![](../../users/profiles/1236128.webp)
Jonathan Komar
- 2,082
- 3
- 21
- 38
2
votes
1 answer
Does Python 3.6 sum() have `start=0` keyword argument?
It seems pretty basic, but as it relates to python language per se, I feel lost here.
According to Python 3.6 documentation :
>>>help(sum)
...
sum(iterable, start=0, /)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers…
![](../../users/profiles/1716733.webp)
Dima Lituiev
- 10,690
- 7
- 32
- 47
2
votes
1 answer
GET() takes 1 positional argument but 2 were given
I am new to web.py and I tried making a simple application where I retrieve a HTML file and display it.
Here is my complete code:
import web
render = web.template.render('templates/')
urls = (
'/(.*)', 'index'
)
class index:
def…
![](../../users/profiles/7201410.webp)
mathmaniac88
- 532
- 5
- 20
2
votes
1 answer
Passing -e and -n as positional parameters in Bash
I've recently been working with positional parameters in some bash scripts and I've noticed that -e and -n do not appear to be passed as positional parameters. I've been searching through documentation but haven't been able to figure out why.…
![](../../users/profiles/10398758.webp)
atw31337
- 23
- 2
2
votes
1 answer
"$1" is empty when running bash -c scriptname arg
I was trying to develop a simple bash script where one positional parameter is used. But for no reason the parameter is empty. The bash script is given bellow.
#!/bin/bash
ulimit -s hard
if [ "$1" != "" ]; then
echo "Positional parameter 1…
![](../../users/profiles/2720125.webp)
C M Khaled Saifullah
- 144
- 2
- 12
2
votes
1 answer
Positional arguments in Python string formatting: str.format vs f-string
When trying out some features with the new (and awesome) python 3 literal string interpolation, I found this weird difference.
For example, using the old str.format, I can format integers with a dynamic number of digits like this:
>>> d = 5
>>> N =…
![](../../users/profiles/4640905.webp)
Jonas Adler
- 8,636
- 2
- 35
- 71