python3.7
OptionParser with a option [ add_option('-t', '--target', action='append', dest='targets') ]
OS: CentOS7.6
So I am using this option to input a list of targets, and with this command line:
parser -t logs* -t test
there's a file "logs.tar.gz" in where I execute this command line, when i print the value of targets, this is what i get:
['logs.tar.gz', 'test']
So I believe this is a 'problem' of system level, and what I want to know is:
is there any way to makelogs*
belogs*
without inputlogs\*
in python?
The shell is who is expanding the *
. There is nothing that python can do here since it never gets to know about the log*
.
You can force your shell to interpret the *
as a literal value with some quoting:
parser -t "logs*" -t test
This works in zsh, it might be different for your shell.