In - Python, inside the the IDLE, in the File Editor Window,
How do you run just a selected single line of code in the script, without having the rest of the lines of the program being runned ?
In - Python, inside the the IDLE, in the File Editor Window,
How do you run just a selected single line of code in the script, without having the rest of the lines of the program being runned ?
You'll have to run your line of code form command line:
With the -c (command) argument (assuming your file is named foo.py):
$ python -c 'import foo; print foo.hello()'
You can use the IdleX extension (https://github.com/serwy/idlex): it adds the ability to run any selected text by pressing F9 (among other things that I haven't tested yet).
You can select and copy a single statement in an Idle editor (or anywhere else, for that matter), switch to the Idle Shell, and paste on the line with the >>> prompt as the bottom. (You can hit to get a clean prompt.) Then hit return just as it you had entered into the shell directly. This works for multiline statements. Being able to do this with a menu selection, hotkey, or right-click selection is on my todo list, as you are not the first to ask about this.
Basically, what we call "debugger" should be fulfilled your requirement. Many IDEs are provided "debugger tools" including IDLE
. To use a debugger tool you can just simply
step
to go to the next breakpoint.This is just a roughly procedure that should be fit to your requirement.
see more: debug
Use a debugger tool. Multiple IDE's provide these within the application or website. You are able to add break lines, which means you are able to stop certain lines of code while the rest of the code runs.
© 2022 - 2024 — McMap. All rights reserved.