Questions tagged [positional-parameter]
104 questions
0
votes
1 answer
Error: get_distance() missing 1 required positional argument: 'point'
Getting Error: get_distance() missing 1 required positional argument: 'point' when the function is already defined with one positional argument called point.
Here is the class:
from math import radians, sin, cos, acos, atan2, sqrt
class…

Scott Bing
- 125
- 4
- 14
0
votes
1 answer
With argparse it it possible to process arguments only up to the last non-positional argument?
I'm writing a tool which passes arguments to another command provided with the arguments like this:
foo --arg1 -b -c bar -v --number=42
In this example foo is my tool and --arg1 -b -c should be the arguments parsed by foo, while -v --number=42 are…

frans
- 8,868
- 11
- 58
- 132
0
votes
0 answers
issue with required parameter
Create a new function named defaults with two parameters:
my_optional which has a default value of True
my_required which is a required param and has no default value
Return the following logical comparison:
my_optional is my_required
Expected…

stumpamo
- 11
- 1
0
votes
1 answer
Use argument in bash command in first part of a pipe
I want to have a simple function or alias in my bashrc that lists files with ls using all my favorite options and pipes the output to more.
Here is how it looks like
l() {
ls -lh --color $1 | more
}
However, when I call this function in a…

Dronakuul
- 147
- 9
0
votes
0 answers
store_response() takes 1 positional argument but 2 were given
I relatively new to the world of Python, and over the past few months I have been going over the exercises in Python Crash Course. I am stuck on the building of a class that takes answers for an anonymous survey. One of the methods of the class is…
0
votes
1 answer
How to set positional parameters in parameter sets?
I wrote a function with four parameters. The first two parameters are mandatory for both sets : Payload and Algorithm.
The last two parameters (Secret and FilePath) define the parameter set.
The order of defined paramters…

Alex_P
- 2,580
- 3
- 22
- 37
0
votes
1 answer
Define variables with positional parameters using for loop in Bash script
Is there a way to define a bunch of positional-parameter variables using loop in Bash?
For example, below is what I want to achieve
mid_1=$1
freq_1=$2
mid_2=$3
freq_2=$4
mid_3=$5
freq_3=$6
mid_4=$7
freq_4=$8
my code:
q=4
q_len=$(( q*2+1…

Liu Yu
- 391
- 1
- 6
- 16
0
votes
1 answer
Flutter '{1} positional argument(s) expected, but {0} found
I tried to make circleImage Widget and use it. but when it's used, it makes error that needs argument. What argument needs in that position?
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
…

Uranus_ly
- 121
- 1
- 6
0
votes
2 answers
Set placeholder argument in psql
Using psql, it seems possible to set named arguments using \pset somevar 'hello'. However there appears to be no way to set a positional argument like $1. This makes it difficult to paste in SQL snippets that use positional arguments. In the sqlite3…

Matt Joiner
- 112,946
- 110
- 377
- 526
0
votes
1 answer
Missing 1 required position argument: 'self'
I'm having an issue with this:
I'm getting the error "
bar() missing 1 required positional argument: 'self'
"
I've tried fiddling this classes (using them and not using them) and with the self variable but I've got nothing. The function bar()…

CoopGod
- 3
- 5
0
votes
1 answer
chop string(arguments passed by user)
suppose the user passed 5 arguments($1 $2 $3 $4 $5), how do I cut off the first two arguments($1 $2) and I only want the last 3 arguments
awk '{print $3,$4,$5} < $@'
what if I don't know how many arguments passed but I do not want the first two…

Bob
- 3
- 4
0
votes
1 answer
Why is my bash script not recognizing the variable in the date command?
If I execute this line within a function of my bash script, it runs successfully:
function myFnc(){
...
variable1=$(date -d 2021-01-01 +%W)
...
}
But if I pass '2021' as input argument by running
myBash.sh '2021'
I get an error "date: date not…

Gpp094
- 35
- 4
0
votes
1 answer
Positional parameter not readable inside the variable - bash script
I have a problem with the small script I am working on, can you please explain why is this not working:
#!/bin/bash
var1=$( linux command to list ldap users | grep "user: $1")
echo $var1
So, when I deploy my script ( ./mycript.sh $michael ), it…

Belphegor
- 49
- 5
0
votes
1 answer
I lose my array values when I use it as input for a positional parameter in bash script
I have written the following script:
cat BaseReCall.sh
#!/bin/bash
#### Usage: < input > < ref > < (array of dbsnps) >
input=$1
ref=$2
Pickle=$3
echo "${Pickle[@]}"
### Assign variables
BaseReCall="gatk BaseRecalibrator \\
-I $input \\
-R…

Ctat41
- 69
- 6
0
votes
1 answer
Assigning argument to a positional parameter
I am calling a shell script that has a large number of arguments e.g. ./train-rnn.sh 0 0 0 "63 512". Is it possible to assign each argument to a specific positional parameter ? e.g.
./train-rnn.sh $1=0 $2=0 $4=0 $3="63 512"

Kong
- 2,202
- 8
- 28
- 56