Advertisement
quantumech

Untitled

Nov 10th, 2020
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. # Preamble
  2. i = 0 # Will be incremented across each file
  3. this_script = open(f"main{i}.py", "r") # Open this script
  4. new_script = open(f"main{i + 1}.py", "w+")
  5. new_script.write(this_script.read().replace("0", "0 + 1")) # Replace i = 0 + ... with i = 0 + .... + 1
  6. new_script.close()
  7. this_script.close() # Create new script
  8.  
  9. # Actual code
  10. print(i**2)
  11.  
  12. # Postamble
  13. exec(f"import main{i + 1}") # Run the new module
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement