Created
August 20, 2013 04:49
-
-
Save goldsmith/6277208 to your computer and use it in GitHub Desktop.
Revisions
-
goldsmith created this gist
Aug 20, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ import os, subprocess ITERATIONS = 5 def transform(line): return "ITERATIONS = " + str(int(line.split()[2]) - 1) + "\n" if line.startswith("ITERATIONS") else line with open(os.path.abspath(__file__), "r+") as f: new = ''.join(map(transform, f.readlines())) f.seek(0) f.write(new) if ITERATIONS > 1: print "iterations left: %s" % ITERATIONS print subprocess.Popen(["python", os.path.abspath(__file__)], stdout=subprocess.PIPE).communicate()[0], else: print "final iteration!"