I just installed Thonny and took a look at some beginner guides. I can easily run whole script by pressing "play" button (or pressing F5). However I could not figure out how to run only some particular lines in the script.
Asked
Active
Viewed 1,879 times
0
-
This isn't directly possible in most programming languages (with a few key exceptions). If you want to run line-by-line, you can either comment out the lines you don't want to run (cmd+/ will usually comment out all the lines currently selected by the cursor) or put in some breakpoints and run it in debug mode. – Green Cloak Guy May 31 '19 at 20:29
-
let’s assume that I have a 5-line script and I run it. after that I add a sixth line into my script. so, what you mean is that it is not possible to run only sixth line and I have to run all (?) I have to run all lines from top to bottom any time I add a new line on my script (?) – Candaş Saldıroğlu May 31 '19 at 20:37
-
Well, yes, because you're *running the script*. If you want to run one line at a time, like to experiment or something, you can open a python console (I don't know how to do this in Thonny, but if you open a command prompt and type `python` you end up in a space where you can essentially write a script continuously executing line-by-line). But in general, running single lines of code isn't that useful, and that's what scripts are for - bundle a bunch of code together so you can run it all at once. – Green Cloak Guy May 31 '19 at 20:41
-
ok then, I understand that I have to run it all over it. So the packages and data sets will be imported every time, variables will be created over and over again and then I get the result. – Candaş Saldıroğlu May 31 '19 at 21:48
-
It is not possible in current version – Aivar Jun 01 '19 at 05:01
1 Answers
0
In Thonny there is a ‘de-bugger’ button at the top (or f6) and if you press that you run through your code one line at a time. It is extremely useful for when you are trying to find out where your code goes wrong. I hope you find this helpful :).

Gileyoncey
- 3
- 1