How can I run a script inside the Python shell effectively?

20 Replies, 1477 Views

Hey! I’ve found that using `subprocess` to call the script works pretty well if you don’t want to mess with exec(). Like:

```python
import subprocess
subprocess.run(['python', 'script.py'])
```

For debugging, I’d recommend using `logging` instead of print statements. It’s more flexible and you can control the output better.

Also, check out Thonny if you’re looking for a simple IDE with a built-in debugger. It’s great for beginners.

Messages In This Thread



Users browsing this thread: 1 Guest(s)