How to write to printer in Windows?

musingattheruins at my-deja.com musingattheruins at my-deja.com
Wed Apr 19 17:45:33 EDT 2000


> From my DOS days, I seem to recall that 'lpt1:' was the correct name
> for the printer device.  lpt1 may be trying to write to a file in a
> directory for which you don't have permission.

You can save the data that you want to print to a text file (say
text.txt) and then call...

   print text.txt

You can do this with a system call...
   import os
   os.system("print text.txt")

or you can go the long way around and try this module....
import printer
p = printer.Printer()
p.open()
p.write("this is some test\nand so is this")
p.close()
del p

You can find it at...
http://musingattheruins.homepage.com/printer.html

L8R,
Bill :-)


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list