Is there any way to preserve the actual function even after wrapping up with a decorator in python

0 votes
@dec_sub
    def sub(a, b):
        c= a-b
        return c
    
    def dec_sub(func):
        def wrapper(a, b):
            if a<b:
                a, b = b, a
            return func(a, b)
        return wrapper
    
    print(sub(48, 9)) # first digit is bigger than the second one yields positive return
    print(sub(1, 8)) # second digit is bigger than the first one also yields positive return
#Output : 39
          7
In the above code, how to use the function 'sub' in a usual way without the influence of the decorator?
Jan 25, 2022 in Python by anonymous

edited 5 days ago 14 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP