1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Rep Power

    Print to line printer

    Re: PyWin 2.7.3

    2 questions:

    How do I print a .txt file to the line printer?

    I have 3 .txt files that I want to print to the line printer.

    All 3 files will fit on one page. How do I concatenate these files to print on 1 page?
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    Load the files into microsoft word and click print?

    Use the DOS print command?

    untested program to concatenate files named on the command line, includes a one line file name separator.

    #use:  A:> python thisfile.py a.txt b.txt 3.txt
    import sys
    for name in sys.argv[1:]:
        print('{} {}'.format('*'*20,name))
        with open(name) as inf:
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Rep Power
    In Linux you can use cat
    cat chapter01 chapter02 chapter03 > book
    and lpr prints
    cat chapter01 chapter02 chapter03 > lpr (assumes you only have one printer)

    If you prefer to use Python, this is a tutorial on reading and writing files.
    Last edited by dwblas; February 19th, 2013 at 10:51 AM.

IMN logo majestic logo threadwatch logo seochat tools logo