Created
September 29, 2014 18:48
-
-
Save akaptur/2accd2dbe8bacb93de40 to your computer and use it in GitHub Desktop.
This file contains 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
def write_chained_functions(total_functions): | |
with open('/usr/share/dict/words','r') as name_file: | |
fn_names = [line.strip() for line in name_file.readlines()] | |
first_name = fn_names[0] | |
last_name = fn_names[total_functions] | |
fn_names = iter(fn_names) | |
with open("empty_chain.py", 'w') as f: | |
name = next(fn_names) | |
following_name = next(fn_names) | |
for _ in range(total_functions): | |
f.write("def %s():\n" % name) | |
f.write(" %s()\n\n" % following_name) | |
name, following_name = following_name, next(fn_names) | |
f.write("def %s():\n print 'yay'\n" % last_name) | |
f.write("%s()" % first_name) | |
if __name__ == '__main__': | |
write_chained_functions(1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment