0

I know that using the code below allows you to open another file

import file
exec(open('file.py').read())

but it doesn't seem to work multiple times, well in tkinter button commands atleast. i expected it to work multiple times but it didn't seem to work, i tried other options like importing Popen from subprocess and using popen to run it, but that didn't work either. is there any way to do this?

update: i've added a second button that runs a program, it runs multiple times but the program doesn't function correctly, i am very confused

Bonnie
  • 1
  • 1
  • 1
    Please refer to this guide on how to provide a [mre], and read about [ask]. Remember, we can't help you if we don't know what you've already tried. – JRiggles Apr 03 '23 at 19:28
  • Can you edit the contents of `file.py`? Because it would be a lot easier to rewrite it to use functions, which you can call as many times as you want from your other module after importing, rather than messing around with other ways of getting it to import twice. – Blckknght Apr 03 '23 at 19:30
  • i could edit the file but the thing is its a whole other program with dozens of functions so it would be very hard to call every single function at once or when needed – Bonnie Apr 03 '23 at 19:33

0 Answers0