python - How to pass script parameters containing spaces or quotes to PyCharm? -
i can run (for command line)
myscript.py '--pm execute.shell(cmd="ls -l", noninteractive=true)'
but, suppose debug myscript.py , set "script parameters:" field in edit configurations python dialog to:
--pm execute.shell(cmd="ls -l", noninteractive=true)
it barfs @ space between "ls" , "-l". there way workaround this? using ' or " quotes seems not it:
--pm 'execute.shell(cmd="ls -l", noninteractive=true)' --pm "execute.shell(cmd='ls -l', noninteractive=true)"
in both cases, quotes end in arguments.
update: running:
import sys x in sys.argv: print "<%s>"%(x,)
with
script parameters: \ b " c" "\ d" ' e' '\ f' "a 'b' \"c\""
gives:
<cmd.py> <a> <\> <b> < c> <\ d> <'> <e'> <'\> <f'> <a 'b' "c">
so looks like:
- escaping ignored (\ treated literally), except preceding "
- a non-escaped " starts block may contain spaces
- ' treated literally
so, magic answer is:
script parameters: --pm "execute.shell(cmd='ls -l', noninteractive=true)"
or
script parameters: --pm "execute.shell(cmd=\"ls -l\", noninteractive=true)"
i not 100% sure issue. since don't have commenting privileges, writing answer.
changing "ls -l" "ls-\ l" should work, @ least on *nix systems.
the relevant documentation/bug report @ https://youtrack.jetbrains.com/issue/py-4715 , https://youtrack.jetbrains.com/issue/idea-72632 states need escape spaces using system dependent methods, , not using generic method. proposal generic system independent method apparently denied.
edit: --pm" "execute.shell(cmd=\"ls" "-l\"," "noninteractive=true) worked.
Comments
Post a Comment