File: class/Workbook/Exercises/Lab8/pack2.py

#!/usr/local/bin/python

import sys, glob                # system module, filename expansion
marker = ':'*6

def pack_files(names):
    for name in names:              # for all command arguments
        input = open(name, 'r')     # open the next input file
        print marker + name         # write a separator line
        print input.read(),         # write the file's contents

if __name__ == '__main__':
    pack_files(glob.glob(sys.argv[1]))    # expand filename pattern



[Home page] Books Code Blog Python Author Train Find ©M.Lutz