Entry
How can I use a line printer from Python on different systems?
Is there system independent access to a line printer from Python?
Mar 3rd, 2000 20:02
Nathan Wallace, Randall Hopper
Well, when you say system-independent, that makes it more of a
challenge:
MSWin: Maybe MSWin provides an abstract API to print to a printer.
But what if there are multiple printers? MSWin progs usually have
a Printer Setup... so the user can set this, among other things
(page parms, orientation, etc.)
UNIX: Is this system using lp? Or lpr? Or ... Assuming we knew,
then the question is which printer (printer queue) does the user
want to use? We might assume the user has already set $PRINTER or
$LPDEST as a preference, but maybe that printer only groks
Postscript and we want to print plain text. Or vice versa.
DOS: How do you know which parallel port has a printer on it, if any?
Maybe none do? Maybe multiple? You could just exec PRINT and take
your chances, but... And you don't know what preamble control
strings might be required. For example, some printers are set to
expect UNIX EOL convention, and some aren't.
For now, it might be best to take your queues off cross-platform apps
like Netscape and let the user configure the command used to print. The
print-to-file option is nice too and useful on occasion.