How to run a python program from the same directory as the source Python code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to run a python program from the same directory as the source Python code?

I have a folder in my drive called "Scripts". In it are "a.py" and "b.py". I want to run "a.py" in "b.py". Not a function, which I know I can use "import". The whole file, almost like "b.py" is a function. So, while "a.py" is running, it would pause for a little bit, where "b.py" would run. How would I do this? If not, is there any external module I can install which does this for me? Thanks very much, VortexYT.

1st Jan 2018, 9:01 PM
VortexYT
3 Answers
+ 7
What you're looking for is the exec() method. Check it out: https://code.sololearn.com/c5f76DBYhYSO/?ref=app
1st Jan 2018, 9:05 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Hey! I had a match against you!! GG btw!
1st Jan 2018, 9:08 PM
VortexYT
+ 2
And thanks!
1st Jan 2018, 9:08 PM
VortexYT