Created
June 6, 2015 00:59
-
-
Save shakna-israel/68fa53e5c7487736c8e0 to your computer and use it in GitHub Desktop.
For Docbuilder
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 characters
filePointer = open('catchme.py', 'r') | |
builtFunc = [] | |
for lines in filePointer: | |
if lines[:3] == 'def': | |
inFunc = True | |
if inFunc == True: | |
if lines[0] == lines.strip(): | |
inFunc = False | |
builtFunc.append(lines.strip()) | |
filePointer.close() | |
print(builtFunc) | |
for item in builtFunc: | |
if '=' in item: | |
exec(item) | |
if 'print' in item: | |
print("Print called on " + item) | |
exec(item) | |
strippedItem = item.strip() | |
if strippedItem[:5] == 'print': | |
pass | |
else: | |
assert False | |
if 'print(' in strippedItem: | |
strippedItem = strippedItem[6:-1] | |
else: | |
strippedItem = strippedItem[5:-1] | |
fileOut = open('outFile', 'w+') | |
fileOut.write('Output:\n```\n' + eval(strippedItem) + '\n```\n') | |
fileOut.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment