DEV Community

Discussion on: 30 Days of Python 👨‍💻 - Day 13 - Decorators

Collapse
 
filipgrano profile image
Filip Granö

Cool series, thanks for making your journey public! It's an interesting read :)

I believe the first example of a higher order function is incorrect, since sum(1,5) is evaluated and then passed as int to the logger function.

I changed it so that the args are passed to logger as a tuple and then unpacked. This way sum is passed as a function to logger.

def logger(func, args): # higher order function
  print(f'The result of the passed function is {func(*args)}')

def sum(num1, num2):
  return num1 + num2

logger(sum, (1,5))
Collapse
 
arindamdawn profile image
Arindam Dawn • Edited

Thanks a lot for the correction :) I have updated my code.
Very glad that you liked the series.