Now when you run the cell, you will get a prompt in the output which you can use to inspect the variables and basically run code live. One way to figure out what is going on is by adding a breakpoint using pdb's set_trace() function: You will find that this is especially true when working with complex functions and classes, unless they happen to be using type hinting. This is a pretty common problem if you don't know what types a function accepts. What this means is that you cannot concatenate a string and an integer. TypeError: cannot concatenate 'str' and 'int' objects TypeError Traceback (most recent call last) ![]() If you run this code, you should end up with some output that looks like this: Let's start by opening up a new Notebook and adding a cell with the following code in it: The pdb module is Python's debugger module. The first one is by using Python's own pdb module. In this chapter we will look at a couple of different methods of debugging a Notebook. But what if you want to debug the code in your Jupyter Notebook? How does that work? ![]() Most Python IDEs have good debuggers built into them. There are many times where I will come to unfamiliar code and I will need to step through it in a debugger to grasp how it works. ![]() The concept of debugging is trying to figure out what is wrong with your code or just trying to understand the code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |