Book Image

Raspberry Pi cookbook for Python programmers

Book Image

Raspberry Pi cookbook for Python programmers

Overview of this book

Table of Contents (18 chapters)
Raspberry Pi Cookbook for Python Programmers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using IDLE3 to debug your programs


A key aspect of programming is being able to test and debug your code, and a useful tool to achieve this is a debugger. The IDLE editor (make sure you use IDLE3 to support the Python3 code we use in this book) includes a basic debugger. It allows you to step through your code, observe the values of local and global variables, and set breakpoints.

How to do it…

To enable the debugger, start IDLE3 and select Debugger from the Debug menu; it will open up the following window (if you are currently running some code, you will need to stop it first):

The IDLE3 debugger window

Open up the code you want to test (via File | Open…) and try running it (F5). You will find that the code will not start since the debugger has automatically stopped at the first line The following screenshot shows the debugger has stopped on the first line of code in filehandler.py which is line 4:import os, shutil.

The IDLE3 debugger at the start of the code

How it works…

The control buttons...