passing argument to script

Sion Arrowsmith siona at chiark.greenend.org.uk
Fri Apr 7 10:45:20 EDT 2006


Daniel Nogradi <nogradi at gmail.com> wrote:
>If you execute your script from the command line on Linux you need to
>enclose it in quotation marks otherwise your shell will interfere. So
>you need to invoke your program as
>
>python yourscript.py "ABCE-123456  ABC_DEF_Suggest(abc def ghi).txt"

Same is true on Windows. It's just that some commands magically convert
filenames with spaces into a single argument if you don't quote them.
(Compare, for instance, cd \Program Files with dir \Program Files .)

>and need to refer to the argument as sys.argv[1:][0]

That's an interesting way of spelling sys.argv[1] .

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list