sys.argv is munging my command line options

Chris Allen ca.allen at gmail.com
Wed Aug 29 15:47:15 EDT 2007


Thanks for the reply. Oops...  I forget that I was calling the program
from a shell script, the shell script was responsible for goofing up
my command line options.  Solved.  Thanks again.


On Aug 29, 12:28 pm, Ant <ant... at gmail.com> wrote:
> On Aug 29, 8:11 pm, Chris Allen <ca.al... at gmail.com> wrote:
> ...
>
> > But I'm running into a problem with this which is that sys.argv splits
> > my key=value options.  I need to know the option associations, and
> > there's no way to know this by inspecting sys.argv.  Can I get access
> > to the command line string as python saw it before it split it into
> > sys.argv or is there another way?  Thanks.
>
> Could you show us some example code that demonstrates this? The
> following works as expected for me on win32:
>
> # test.py
> import sys
>
> for arg in sys.argv[1:]:
>         print arg
>
> >From the command prompt:
>
> C:\0>test.py action key=value key=value
> action
> key=value
> key=value
>
> --
> Ant.





More information about the Python-list mailing list