tempfile Question

Gregory Piñero gregpinero at gmail.com
Tue Jun 6 23:50:46 CEST 2006

Hey group,

I have a command line tool that I want to be able to call from a
Python script.  The problem is that this tool only writes to a file.

So my solution is to give the tool a temporary file to write to and
then have Python read that file.  I figure that's the safest way to
deal with this sort of thing.  (But I'm open to better methods).

Here's my code so far, could anyone tell me the proper way to use
tempfile.  This code won't let the tool write to the file because
Python has it locked.  But I'm worried that if I close the file then
windows might take it away?  I have no idea.


def read_pdf_text(filepath):
    command=r'"%s" "%s" "%s"' % (PDFTOTEXTPATH,filepath,outfilename)
    return pdftext

Much thanks!

Gregory Piñero
Chief Innovation Officer
Blended Technologies

More information about the Python-list mailing list