Python How to Load a .py File in the Python Interactive Shell for Debugging?

AI Thread Summary
To load a .py file in the Python interactive shell for debugging, use the command "python -i filename.py". This command executes the specified Python file and then enters interactive mode, allowing users to interact with the environment created by the script. Additionally, some users incorporate this functionality directly into their scripts by starting with the shebang line "#!/usr/bin/python -i", enabling immediate access to the interactive shell upon execution. This method facilitates debugging by maintaining the context of the script's execution.
sid_galt
Messages
502
Reaction score
1
How can I load a .py file in the python interactive shell for debugging?
 
Technology news on Phys.org
If you open the python interpreter by typing:

python -i filename.py

It will execute filename.py and then drop you into interactive mode with the environment left behind by filename.py.

I sometimes build this directly into my scripts, for example by beginning with:

#!/usr/bin/python -i
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
11
Views
1K
Replies
2
Views
779
Replies
8
Views
1K
Replies
8
Views
2K
Replies
10
Views
2K
Replies
11
Views
2K
Replies
16
Views
6K
Back
Top