How it works...

In this section, we'll see how to simply move through the code by using the next statement, which continues execution until the next line in the current function is reached or returned.

To use rpdb, follow these steps:

  1. Import the relevant rpdb library:
import rpdb
  1. Set the debugger parameter, which specifies the telnet port to connect to in order to run the debugger:
debugger = rpdb.Rpdb(port=4444)
  1. Call the  set_trace()  directive, which makes it possible to enter into debugging mode:
rpdb.Rpdb().set_trace()

In our case, we placed the set_trace() directive immediately after the debugger instance. In reality, we can place it anywhere in the code; for example, if conditions are satisfied, or within a section managed by an exception.

The second step, instead, consists of opening Command Prompt and launching telnet by setting the same port value specified in the debugger parameter definition within the sample code:

telnet localhost 4444

It is possible to interact with the rpdb debugger by using a small command language that allows movement between calls to the stack, to examine and to modify the values of the variables and control the way in which the debugger executes its own program.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.121.55