Answer the question
In order to leave comments, you need to log in
How to escape an element on the command line (argpars module)?
Hello!
You need to write a command line utility to sort movies.
There is an argument -genres - this is a filter by genre, set by the user. may be multiple. for example, Comedy|Adventure or Comedy&Adventure. optional
That is, in the console you can enter:
python3 example_one.py -genres Comedy # and this command works in the console
But you need to be able to filter by several genres at once, for example,
python3 example_one.py -genres Romantic|Drama # this command does not work in the
python3 console example_one.py -genres Romantic&Drama # this command also doesn't work
here is what is written in the console when these two commands are executed:
zsh: command not found: Drama
Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
here's what the add_argument method looks like:
parser.add_argument('-genres',
type=str,
help='filter by genre'
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question