Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run python code line by line in Spyder and include loop/if statement contents

Tags:

python

spyder

I usually use RStudio to code in R, and when running code line by line, if running the first line of a loop, the content of the loop runs with it. It is very convenient for debugging code, to be able to run code line by line without manually selecting the whole loop for example. In Spyder, if I run the first line of a loop, it runs just that, as if I was trying to run an empty loop, and gives an error. How can a run a code line by line properly in Spyder? I have researched the question but did not find an answer. Thank you for your help!

like image 487
arielle Avatar asked Jan 24 '18 19:01

arielle


1 Answers

(Spyder developer here) This problem has been reported before but we haven't had time to solve it. Although it sounds simple, it's really hard to solve correctly in all situations because indentation spaces matters in Python (whereas in R they are irrelevant).

like image 182
Carlos Cordoba Avatar answered Nov 14 '22 23:11

Carlos Cordoba