Printing in a generic way - like the rest of Python
Terry Reedy
tjreedy at udel.edu
Tue May 13 13:53:20 EDT 2003
"Ed Connell" <connell at noflashspam.net> wrote in message
news:0r0wa.386$vs.311 at newssvr17.news.prodigy.com...
>
> No, I mean something as simple as printing an ASCI text file. (I
mean
> sending the file to the system printer.) My program ran just fine
in Linux,
> (I used system( 'lpr %s' % filename ) and it worked just fine.
'system' call are not generic as they depend on program loaded and
accessible on particular system.
>Now I want to make the same program run in MS-Windows, and wondered
if there is some
> generic way to send files to the printer as there are generic ways
to delete
> a file, say, and all sorts of other stuff.
This might actually be a be a nice enhancement to os module...
> If the answer is no, then my next question is, how do you print a
file in
> the Windows world.
Usually, from within an application that knows how to print a
particular file type by selecting 'print' on its 'file' menu. For
ASCII text, Notepad works. From an MSDOS prompt, "type file >lpt1:"
does it (assuming your printer is connected to parallel port 1), but
this does not send a formfeed, so you will have to hit the formfeed
button on your printer. This does not work from the windows Run
prompt (on my machine), but this, for example, does:
os.system(r"type c:\Python\tem.txt >lpt1:")
Terry J. Reedy
More information about the Python-list
mailing list