Printing from python on Windows platform

Darrell news at
Tue Aug 3 20:48:16 EDT 1999

Printing from Windows isn't so straight forward.
I've seen printing support in wxPython.

In the old DOS days you could write to lpt1:

E:\dgXXX>copy win.cfg lpt1:
        1 file(s) copied.

Nothing came out of my printer.

E:\dgXXX>dir lpt*
 Volume in drive E has no label.
 Volume Serial Number is 541E-3EC8

 Directory of E:\ace\v2\data\dgXXX

File Not Found

E:\dgXXX>copy win.cfg stdout:
"stdout:" is not a recognized device.
The system cannot find the file specified.

I'm using NT 4.0

Johann Spies <jhspies at> wrote in message
news:Pine.LNX.3.96.990803232344.254A-100000 at Johann...
> I am sorry to ask this a second time, but I did not receive any hint
> after the first time I put this question to the list.
> I am a Linux user writing a program for somebody that will use it on a
> Windows platform.  In Linux I use the following to redirect printing to
> the printer:
>     drukker = sys.stdout
>     drukker = os.popen('lpr','w')
>     drukker.write(drukstuk)
>     sys.stdout.write(drukstuk)
> What would the windows equivalent be?
> I have tried os.popen('prn', 'w'), but without success.  I cannot see
> anything in the python documentation to help me.
> Johann
>  -------------------------------------------------------------------------
> | Johann Spies                                 Windsorlaan 19
> | jhspies at                3201 Pietermaritzburg
> | Tel/Faks Nr. +27 331-46-1310        Suid-Afrika (South Africa)  |
>  -------------------------------------------------------------------------
>      "Have not I commanded thee? Be strong and of a good
>       courage; be not afraid, neither be thou dismayed; for
>       the LORD thy God is with thee whithersoever thou
>       goest."                        Joshua 1:9

More information about the Python-list mailing list