[code.view]

[top] / python / PyMOTW / fileinput / fileinput_change_subnet.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Simplistic grep implementation
     """
     #end_pymotw_header
     
     import fileinput
     import sys
     
     from_base = sys.argv[1]
     to_base = sys.argv[2]
     files = sys.argv[3:]
     
     for line in fileinput.input(files, inplace=True):
         line = line.rstrip().replace(from_base, to_base)
         print line
     

[top] / python / PyMOTW / fileinput / fileinput_change_subnet.py

contact | logmethods.com