Python Essentials Classroom Series – 15/Aug/2021

Inner functions in python

  • In python we have a function defined with in another function
def outer():
    def inner():
        return 'hello'
    return inner()

Decorators

  • Sometimes we need to modify the existing functions without changing it’s source code
  • Probaly adding debug statements
  • A Decorator is a function that takes one function as input and returs another function
  • To write decorators, we need to know the following
    • *args and **kwargs
    • Inner Functions
    • Function as an argument
  • For using function as argument Refer Here
  • Refer Here for the decorator added to sum of prime numbers

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin