@@ -0,0 +1,1543 @@
+#! /usr/bin/env python%0A'''%0Ahead.py - Unix copy of head command. %0A'''%0A%0A%0Aimport sys, argparse, os%0A%0Adef parse_args():%0A    '''%0A    command line arguments%0A    '''%0A%0A    parser = argparse.ArgumentParser()%0A%0A    parser.add_argument('file_path',%0A                        nargs='*',%0A                        type=str,%0A                        help='file path to print first ten lines.')%0A%0A    parser.add_argument('-v',%0A                        dest='verbose',%0A                        action='store_true',%0A                        default=False,%0A                        help='always output headers giving file names')%0A%0A    parser.add_argument('-n',%0A                        dest='lines_out_put',%0A                        nargs='?',%0A                        default=10,%0A                        type=int,%0A                        help='Number of lines to output instead of 10.')%0A%0A    return parser.parse_args()%0A%0A%0Adef head(file_path, verbose=False, lines_out_put=10):%0A    '''%0A    Unix command head%0A%0A    Args:%0A        file_path (str%7Clist):          File for printing out first 10 lines.%0A        verbose (bool):                Always output headers giving file name.%0A    '''%0A%0A    if verbose:%0A        sys.stdout.write(str('==%3E' + file_path%5B0%5D +'%3C==' + '%5Cn'))%0A%0A    with open(file_path%5B0%5D, 'r') as f:%0A        lines = %5Bnext(f) for x in xrange(lines_out_put)%5D%0A        sys.stdout.write('%5Cn'.join(lines))%0A%0A%0Adef main():%0A    '''%0A    main%0A    '''%0A%0A    args = parse_args()%0A    head(args.file_path, args.verbose, args.lines_out_put)%0A%0A%0Aif __name__ =='__main__':%0A    sys.exit(main())%0A

Create head.py