passing arguments with ampersands

SHY soundplay at
Sat Aug 18 14:24:35 CEST 2007

theres no special portion of code, just the one that handles filenames with
the problem is that when i associate a file extension to my application and
i open it, the filename is not quoted before passed as an arguement. i dont
know if its the problem of windows or something, or it was just my fault
when i incorrectly associated the extension.
anyway, this is the code that outputs the second quote i posted in the
original message:

args = None
> if len(sys.argv) > 1:
>     args = sys.argv[1:]
print args

and this is the code that handles the filenames with spaces (as space
generally delimits cmdline params). its not very ellegant, needs a bit of
tuning, but it works (i dont use any kind of -d --something params yet).

newargs = []
if args:
    first = None
    for arg in args:
        if not first:
            first = arg

        if os.path.isfile(first):
            first = None

        if arg.find(":") == -1:
            first = " ".join([first, arg])

    if first:

how can i make the params get quoted before send as arguments?

thanks in advance.

> 2007/8/18, O.R.Senthil Kumaran <orsenthil at>:

> Quote:D:\ftp\Music\Mixes & Compilations\Above & Beyond - Essential
> > Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt
> > when i put 'print sys.argv[1:]' at the very beginning of the script, all
> i
> > get is this:
> >
> > Quote:['D:\\ftp\\Music\\Mixes']
> >
> Can you share the portion of the code?
> Are you quoting the argument that you are passing?
> for e.g:
> #cat
> import sys
> print sys.argv[1]
> #python "I am able to print the spaces and & characters"
> I am able to print the spaces and & characters
> --
> O.R.Senthil Kumaran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list