Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run python source code line by line

Tags:

python

Given a Python source code, is it possible to run the code line by line, as if you were debugging?

And when it comes to a function call, I would like to 'step into' the function also.

like image 637
user11869 Avatar asked Oct 06 '11 23:10

user11869


People also ask

Can I run Python code line by line?

One thing that distinguishes Python from other programming languages is that it is interpreted rather than compiled. This means that it is executed line by line, which allows programming to be interactive in a way that is not directly possible with compiled languages like Fortran, C, or Java.

How do I run a line of code in Python?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!

How do I run a Python script from the command line with example?

The most basic and easy way to run a Python script is by using the python command. You need to open a command line and type the word python followed by the path to your script file, like this: python first_script.py Hello World! Then you hit the ENTER button from the keyboard and that's it.


1 Answers

python -m pdb <script.py> will run the script in the Python debugger.

like image 123
Michael Hoffman Avatar answered Oct 14 '22 00:10

Michael Hoffman