Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:23:22+00:00 2026-06-10T06:23:22+00:00

What are some examples of the different incarnations of function-type and class-type, argument and

  • 0

What are some examples of the different incarnations of function-type and class-type, argument and no-argument decorators in Python?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:23:24+00:00Added an answer on June 10, 2026 at 6:23 am
    def decorator_noarg(f):
        def wrapper(*args, **kwargs):
            print("Inside decorator-function, WITHOUT arg.")
            return f(*args, **kwargs)
        return wrapper
    
    def decorator_witharg(dec_arg):
        def real_decorator(f):
            def wrapper(*args, **kwargs):
                print("Inside decorator-function, WITH arg: %s" % (dec_arg))
                return f(*args, **kwargs)
            return wrapper
        return real_decorator
    
    class decoratorclass_noarg(object):
        f = None
        def __init__(self, f):
            def host_wrapper(*arg, **kwargs):
                print("Inside decorator-class, WITHOUT arg.")
    
                # We lose the original instance of the object.
                return f(test_class(), *arg, **kwargs)
    
            self.f = host_wrapper
    
        def __call__(self, *args, **kargs):
            return self.f(*args, **kargs)
    
    class decoratorclass_witharg(object):
        f = None
        def __init__(self, dec_arg):
            def decorator(host_method):
                def host_wrapper(host_obj, *arg, **kwargs):
                    print("Inside decorator-class, WITH arg: %s" % (dec_arg))
                    return host_method(host_obj, *arg, **kwargs)
                return host_wrapper
            self.f = decorator
    
        def __call__(self, *args, **kwargs):
            return self.f(*args, **kwargs)
    
    class decorator_on_function_noarg(object):
        f = None
    
        def __init__(self, f):
            self.f = f
            pass
    
        def __call__(self):
            print("Inside decorator-on-function class, without arg.")
            return self.f()
    
    class decorator_on_function_witharg(object):
        f = None
    
        def __init__(self, dec_arg):
            def decorator(host_method):
                def host_wrapper(*arg, **kwargs):
                    print("Inside decorator-on-function class, with arg: %s" % (dec_arg))
                    return host_method(*arg, **kwargs)
                return host_wrapper
            self.f = decorator
    
        def __call__(self, *args, **kwargs):
            return self.f(*args, **kwargs)
    
    def decorator_function_on_method_noarg(f):
        print("Inside decorator-function on method, without arg.")
        return f
    
    def decorator_function_on_method_witharg(dec_arg):
        def wrapper(f):
            print("Inside decorator-function on method, with arg: %s" % (dec_arg))
            return f
    
    # Testing calls.
    
    class test_class(object):
        #@decorator_witharg(44)
        #@decorator_noarg
        #@decoratorclass_witharg(1)
        #@decoratorclass_noarg
        #@decorator_function_on_method_noarg
        #@decorator_function_on_method_witharg(33)
        def test_func(self, arg1, arg2):
            print("Inside: %s, %s" % (arg1, arg2))
            return 123
    
    #@decorator_on_function_noarg
    #@decorator_on_function_witharg(22)
    def test_func():
        print("Inside test_func.")
    
    #test_class().test_func(33, 44)
    #test_func()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some examples of implementing curry function in ruby(1.8.6 or 1.8.7 not 1.9).
I am following some examples in the book, and I noticed two different conventions
what is different between ajax and webservices. Anybody provide with some examples?
Can anybody show with some examples the exact difference between .. and ... operator?
I have some data similar to the following chart: http://developer.yahoo.com/yui/examples/charts/charts-seriescustomization_clean.html Only difference is that
I am trying out some examples with analytical functions and i have created a
Here are some examples of strings (mainly addresses): 12 20 43-B 43-C 123 2500
I was reading some examples on symbols in ruby, and one example was using
I've found some examples of .AVI in html on the web. But my page
I want some examples of C preprocessor directives, such as: #define pi 3.14 #define

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.