passing arguments with ampersands
soundplay at gmail.com
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
args = None
> if len(sys.argv) > 1:
> args = sys.argv[1:]
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 = 
first = None
for arg in args:
if not first:
first = arg
first = None
if arg.find(":") == -1:
first = " ".join([first, arg])
how can i make the params get quoted before send as arguments?
thanks in advance.
> 2007/8/18, O.R.Senthil Kumaran <orsenthil at users.sourceforge.net>:
> 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
> > 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 1.py
> import sys
> print sys.argv
> #python 1.py "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...
More information about the Python-list