Firstly - I'm a complete noob when it comes to Python. I'm currently trying to launch an external program called Dazzle from Python with a the path to an xml file as a parameter.

I've tried a few different options and can get Dazzle to launch - but the xml file is not processed. Below is the script being used:

From windows command line (works as expected)

DAZZLE tmp\file.xml

Python script:

#!c:/Python30/python.exe -u
# -*- coding: windows-1252 -*-
import os
import subprocess	
from subprocess import call

p = call('DAZZLE tmp\163282.xml')

Dazzle launches, but the xml file does not get run. I've tried a few different option - nothing seems to work.

Any suggestions will be greatly appreciated

not specifically answer to your question, but there is duplication of subprocess imports
Just use one

from subprocess import call

I have always found it necessary to use shell=True, on Linux machines anyway.
p = call('DAZZLE tmp\163282.xml', shell=True)

I think I have a partial fix - seems like I needed to have that XML file in the same directory as the script calling it. Not sure why - tried both absolute and relative paths.

The shell=True didn't seem to help; the script still ignored the xml file unless it was in the same dir.

absolute and relative paths.

Rember to use \\ or /(windows)
\ count as a new line.

So as an example.
c:/tmp/163282.xml
or
c:\\tmp\\163282.xml

if windows you can use code below(Just alternative). Not tested though

import os
os.system("myprog //mydir_where_there_is_xm//myxml.xml")

You dont need two //,only if it is this way \\.

So this will work on windows.
os.system("myprog /mydir_where_there_is_xm/myxml.xml")

You dont need two //,only if it is this way \\.

So this will work on windows.
os.system("myprog /mydir_where_there_is_xm/myxml.xml")

Looks like it was just a path problem - though I swear I tried with both the / and \\. Thanks for all the suggestions, here is the working code:

p = subprocess.Popen('c:\\path\\to\\exe c:\\path\\to\\xml',shell=True)

FYI, os.path.join() will take care of this on any OS
print os.path.join('c:', 'path', 'to', 'exe')

This question has already been answered. Start a new discussion instead.