using argparse with runscript?
See original GitHub issueIs there a way to use argparse in combination with runscript? The only way I have found to pass arguments to my script from the command line is to do something like this:
python manage.py runscript myscript --script-args="1,a,banana"
Which is a little cryptic. What I’d like to be able to do is say:
python manage.py runscript myscript --number=1 --letter=a --fruit=banana
If I try to wrap up my args in quotes, like so:
python manage.py runscript myscript --script-args="--number=1 --letter=a --fruit=banana"
I get messages about “unknown parameter ‘number’”, which leads me to think that that’s being raised by the runscript command.
Any hints appreciated, or if there’s a good idea about how to implement this, I’d give it a try.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Run python script with argparse in another script
I have a python script which uses some input parameters via argparse. something like this: **hello ...
Read more >How To Use argparse to Write Command-Line Programs in ...
argparse allows you to call your own custom Python code with command-line arguments similar to how you might invoke git , ls ,...
Read more >Build Command-Line Interfaces With Python's argparse
In this new implementation, you first import argparse and create an argument parser. To create the parser, you use the ArgumentParser class.
Read more >python - structure a script with main, parse_args, subprocess
Run: ./script.py. Read in the R1.fastq read file. At the top of the script, import the modules argparse and sys; Define a function...
Read more >Command Line Arguments in Python
Using sys.argv; Using getopt module; Using argparse module. Using sys.argv. The sys module provides functions and variables used to manipulate ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have not looked at this in a long time. IIRC, the underlying issue was that the “unrecognized arguments” error is raised by Django code, not by the django-extensions code. FWIW, I have started doing things this way:
and then my invocation looks like
closing due to inactivity