How can I use printer port in python?...

Jeff Epler jepler at
Mon Dec 11 08:39:35 EST 2000

On Sun, 10 Dec 2000 20:02:24 +0900, skidrow at
 <skidrow at> wrote:
>As the title says, I was wondering if there's anyway I can
>use printer port in python...

In Unix, if your printer is named /dev/lp1, just use
	f = open("/dev/lp1", mode)
and then look at the contents of the fcntl and FCNTL modules
for ways to perform low-level manipulation of the printer.

If you want to just write output to the printer, use
	f = os.popen("lpr", "w")
and write to f.  You may need to get arguments to lpr, such as
"-p<printer name>".

There is bound to be a way to do it on Windows, but I don't have a clue how.

There is probably no cross-platform way.


More information about the Python-list mailing list