Best way to create temporary file?

Frank Millman frank at chagford.com
Sun May 1 04:34:16 EDT 2005


Frank Millman wrote:
> > Hi all
> >
> > I need to generate potentially large reports from a database, and I
> > want to offer the option of print preview before actually printing
> > (using wxPython). I figure that the best way to achieve this is to
> > write the report to a temporary file, or more likely to a temporary
> > directory with a separate file for each page. I can use that for
> > previewing and for printing, and then delete the file/directory.
> >

Fabio Pliger wrote:
>  Why create an intermediate file to preview with wxPython? I would just
> preview the data with wx and keep it inside your application. If you want to
> print it just print... avoid temp file creation if it's not necessary... :)
> 
> F.P.

It depends on what you mean, Fabio.

If a report contains sub-totals, page breaks, etc, it is not possible
to preview a particular page at random without generating the entire
report first.

It is certainly possible to store the entire report in memory, using a
two-dimensional list (page/line), but if a report runs into hundreds of
pages, I am concerned at the amount of memory this would require.
Perhaps I am being old-fashioned - with todays memory of at least 64k,
it would probably fit without a problem - but I would prefer to write
the pages away and read them back when needed.

Frank



More information about the Python-list mailing list