[SPAM] Re: How do you write to the printer ?

MRAB google at mrabarnett.plus.com
Thu Jan 8 01:00:00 CET 2009

David at bag.python.org wrote:
> On Wed, 07 Jan 2009 15:17:19 -0800, Scott David Daniels
> <Scott.Daniels at Acm.Org> wrote:
>> David Lemper wrote:
>>> Can find nothing in the on-line docs or a book.
>>> Groping in the dark I attempted :
>> Note that (1) You may have just created a file named stdprn.
>>           (2) You need to close that file bwhen you are done.
>>           (3) A final end-of-line is traditional.
>>           (4) You could give us a clue about your operating environment.
>>               (To wit: os, version, python version)
>> A printer is nothing Python has or controls, it is  a standard thing for
>> a computer system, so details about your computing environment are
>> necessary in order to give you good advice.
>> --Scott David Daniels
>> Scott.Daniels at Acm.Org
> Thanks Scott.  System is Windows XP on an Intel, Python version 3.0
The simplest way on Windows is opening "PRN:" or "LPT1":

     printer = open("PRN:", "wb")

where 'binary_data' is a bytestring (class 'bytes' in Python 3.x).

More information about the Python-list mailing list