Doesn't anybody write to paper anymore?

Fredrik Lundh effbot at telia.com
Thu Apr 13 20:00:57 CEST 2000


Albert Wagner <alwagner at tcac.net> wrote:
> I've searched the docs and my "Learning Python" book and I can't find
> anything on printing to a real printer.  Through trial and error I
> finally made the following work:
>
> printer = open('/dev/lp0', 'w')
> printer.write("page 1\n\r\f")
> printer.write("page 2\n\r\f")
> printer.close

oh, you're on unix...

this might work:

    printer = os.popen("lpr", "w")
    printer.write("page 1\n\f")
    printer.close()

for more information, read the OS documentation for
lpr and friends.

</F>





More information about the Python-list mailing list