Python Forum
Decorator is using in class,but not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Decorator is using in class,but not working
#2
Your decorator extract_function_name does not need to be in class ScientificCalculator
and it needs to return internal_method, at the moment it defaults to returning None.
def extract_function_name(func):
    def internal_method(*args,**kwargs):
        print('the method called is:',func.__name__)
        returned_value = func(*args,**kwargs)
        print('the method execution is complete')
        return returned_value
    return internal_method 
Reply


Messages In This Thread
RE: Decorator is using in class,but not working - by Yoriz - Jul-04-2020, 08:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  function-decorator , which is checking an access according to USERNAME Liki 6 769 Feb-17-2024, 03:36 AM
Last Post: deanhystad
  Decorator for a function with argument(s) banidjamali 1 1,906 Feb-09-2021, 11:55 AM
Last Post: Gribouillis
  i got a decorator question yosef 3 2,702 Aug-25-2020, 04:14 PM
Last Post: DeaD_EyE
  Decorator and namespace. JayIvhen 2 2,890 Oct-26-2018, 03:56 PM
Last Post: nilamo
  python decorator alfredocabrera 0 3,191 Feb-22-2017, 07:04 AM
Last Post: alfredocabrera

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020