Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Preamble
- i = 0 # Will be incremented across each file
- this_script = open(f"main{i}.py", "r") # Open this script
- new_script = open(f"main{i + 1}.py", "w+")
- new_script.write(this_script.read().replace("0", "0 + 1")) # Replace i = 0 + ... with i = 0 + .... + 1
- new_script.close()
- this_script.close() # Create new script
- # Actual code
- print(i**2)
- # Postamble
- exec(f"import main{i + 1}") # Run the new module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement