Passing arguments with spaces in Run options
kenficara last edited by
Under the wrench icon in Pythonista there is a “Run options” button with an input field to add arguments. If I enter “first argument”, “second argument” into that field, argv will contain [“first”, “argument”, “second”, “argument”]. How does one pass arguments with spaces here?
ccc last edited by
https://docs.python.org/3/library/urllib.parse.html#url-quoting contains the general idea.
s.replace(" ", "+")and if that does not work, try
s.replace(" ", "%20").
cvp last edited by
@kenficara see local doc
Example: pythonista://MyScript?action=run&args=foo%20bar When you pass a single string with the args URL parameter, the string is split by spaces (the space is encoded as %20 here) and sys.argv would be [<script_path>, 'foo', 'bar'] in this example. If you want to pass arguments that contain spaces, you have to enclose them in double quotes (as you would in a classic shell). This is basically the same as running a script by long-pressing the run button.
superb-james last edited by
This post is deleted!