Printing in a generic way - like the rest of Python
Thomas Heller
theller at python.net
Tue May 13 02:57:20 EDT 2003
> > >How can I print a file in a generic way in both Widows and Linux? I've
> > >searched for the answer but have not found it.
> >
> > I assume you mean something more than basic ASCII text?
> >
>
> 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. 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.
I just tried this, and it worked (on XP pro, with a printer connected
via network):
p = open("lpt1:", "w")
p.write("Hello, World\n")
p.close()
Thomas
More information about the Python-list
mailing list