When using optparse i want to get the whole string after an option, but I only get part of it up to the first space.
e.g.:
python myprog.py --executable python someOtherProg.py
What I get in 'executable' is just 'python'.
Is it possible to parse such lines using optparse or do you have to use argparse to do it?
€: I have already tried enclosing it in "s. But after digging further into the code I found out that the subprocess invocation can't handle the argument.
The string with the commandline gets crammed into a list 'args'.
args = [self.getExecutable()] + self.getArgs().split()
It's like
"[python D:\\\workspace\\\myprog\\\src\\\myprog.py]"
That gives me the System can't find file exception. When I use
args[0]
it works. But I loose the arguments to the executable.
The subprocess module builds a cmdline from a list if it does not get a string in the first place, so I can't explain that behavior at the moment.
silly python some
:argv[1]
="python"
,argv[2]
="some"
.silly "python some"
:argv[1]
="python some"
. Andsilly python\ some
:argv[1]
="python some"
. But with Python 3.5 we havesilly.py python some
:argv[1]
="python"
,argv[2]
="some"
.silly.py "python some"
:argv[1]
="python some"
. Andsilly.py python\ some
:argv[1]
="python\\"
,"some"
. Amazing! – Funk