I’ve been in your shoes! Running a Python file from another Python function can be tricky, but `subprocess` is the way to go.
Here’s a tip: if you need to capture the output of the script, use `subprocess.Popen` with `stdout=subprocess.PIPE`.
```python
import subprocess
process = subprocess.Popen(["python", "your_script.py"], stdout=subprocess.PIPE)
output, _ = process.communicate()
print(output.decode())
```
This is super useful for debugging or logging.
Here’s a tip: if you need to capture the output of the script, use `subprocess.Popen` with `stdout=subprocess.PIPE`.
```python
import subprocess
process = subprocess.Popen(["python", "your_script.py"], stdout=subprocess.PIPE)
output, _ = process.communicate()
print(output.decode())
```
This is super useful for debugging or logging.
