Print to printer

Magnus Lycka lycka at carmen.se
Tue Nov 1 07:37:03 EST 2005


avnit wrote:
> I can't seem to figure out how to print with my printer using python.
> I'm using Mac OSX 10.4. I was thinking maybe something with
> applescript. Does anyone know?

Mac OSX is unix, right?

This ought to work then:
 >>> import os
 >>> printer = os.popen('lpr', 'w')
 >>> printer.write('This is a test.\n')
 >>> printer.close()

Try to get 'lpr' or 'lp' to work from a command line.
You should be able to use 'lpstat -p' to figure out
printer names if you need that (then use 'lpr -P ps'
to print to a printer called ps.)



More information about the Python-list mailing list