3 ms·
Yeap. I find it great for prototyping: I code in the IPython shell, and then I dump the code of the various functions I wrote to a file, using func_code. d
by icebraining 15y ago
Yeap. I find it great for prototyping: I code in the IPython shell, and then I dump the code of the various functions I wrote to a file, using func_code.
def makedumper(filen):
def dumpfunc(func):
with open(filen, 'a') as f:
file.write("\n\n{}".format(func.func_code))
return dumpfunc
#then to use it:
dump = makedumper("sourcefile")
dump(func1)
dump(func2)