Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • what is the use of "@aNewDecorator" and "@wraps(aFunc)" in this decorators and how can i get my output?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 261
    Answer it

    from functools import wraps
    def aNewDecorator(aFunc):
        @wraps(aFunc)
        def wrapTheFunction():
            print("Iam doing some boring work before executing aFunc().")
            aFunc()
            print("Iam doing some boring work after executing aFunc().")
        return wrapTheFunction
    @aNewDecorator
    def aFunctionRequiringDecoration():
        print("Iam the function which needs some decoration to remove my foul smell")
        print(aFunctionRequiringDecoration.__name__)
        
        
     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: