Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Debugging Code With Decorators

In this lesson, you’ll see how to create a decorator for debugging code. You’ll see how the @debug decorator prints out the arguments a function is called with as well as its return value every time the function is called.

Sagar on March 28, 2019

Thanks for the awesome tutorial on Decorators. If I had to study decorators for an interview this would be my one stop shop for decorators starting right from the Beginner

Sagar on March 28, 2019

Thanks for the awesome tutorial on Decorators. If I had to study decorators for an interview this would be my one stop shop as it goes right from BASICS to a bit ADVANCED on one topic. Unlike a few other tutorials like OOPS which finished at a BEGINNER stage. Would have appreciated it even more had it cover some more advanced topics like multiple inheritance and usage of super. As I mentioned earlier many of us would like these video courses to be a one stop shop for any topic that is newly introduced. Thanks for all the effort in putting this together. One small feedback , if we could select a default video resolution for an entire topic or series instead of choosing manually for each video/lecture

AugustoVal on March 28, 2019

Hello,

Thank you for the tutorial. Quick question.

Do you need always the boiling script to run the others?

Chris Bailey RP Team on March 28, 2019

Hi AugustoVal! The ‘boilerplate’ part of the decorators module isn’t required for running or applying the decorators to your functions. It is in the tutorial and used to give you a template for copying and modifying to your needs. It is not called or referenced in the other code.

Dan Bader RP Team on June 18, 2019

@Anonymous:

One small feedback , if we could select a default video resolution for an entire topic or series instead of choosing manually for each video/lecture

I just added that as a feature—you can set the default video quality in your account settings :)

Tumise on Dec. 24, 2019

hey i just wanted to find out why, doing this ” sqrt = debug(sqrt) gave and error but “math.sqrt = debut(math.sqrt)” did not. the error message was SyntaxError: invalid syntax

Chris Bailey RP Team on Dec. 27, 2019

Hi Tumise, It’s hard to tell what your SyntaxError could have been from without a bit more context. If I were to guess why it worked properly in your second example, instead of the first. You imported the math module by typing in ‘import math’. In that case you would need to prefix all the ‘math’ functions/methods with ‘math. ‘ to access them, such as ‘math.factorial’ or ‘math.sqrt’. If you were to import ‘sqrt’ by itself using ‘from math import sqrt’ you could then access it by typing only ‘sqrt’.

Become a Member to join the conversation.