How do you print?

Jeff Shannon jeff at ccvcorp.com
Wed Mar 6 18:39:46 EST 2002


Peter Scott wrote:

> How can you print to a printer in Python? I know that you can do
> platform-dependant things like using lpr (on UN*Xlike systems) or
> "wordpad -p myfile" on windows, but that doesn't seem to be the Python
> Way.
>
> I just need to print--for now--plain text. Can anyone help me?

AFAIK, Python has no built-in cross-platform printer facilities.  Various
GUI toolkits do include printing frameworks, but if you're only needing to
print plain text, they're almost certainly overkill.  Your best bet is
probably to abstract your printing needs into a single module with a
consistent, well-defined interface, and then implement that module in the
most natural way for each platform that you need to be able to run on.
Not the most desirable solution, but probably the most practical.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list