theres no special portion of code, just the one that handles filenames with spaces. 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). [code] newargs = [] if args: first = None for arg in args: if not first: first = arg continue if os.path.isfile(first): newargs.append(first) first = None continue if arg.find(":") == -1: first = " ".join([first, arg]) if first: newargs.append(first) [/code] how can i make the params get quoted before send as arguments? thanks in advance. > > 2007/8/18, O.R.Senthil Kumaran <[EMAIL PROTECTED]>: > 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 1.py > import sys > print sys.argv[1] > > #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 > http://uthcode.sarovar.org >
-- http://mail.python.org/mailman/listinfo/python-list