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

  • Home
  • SEARCH
  • 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 5841143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:51:04+00:00 2026-05-22T11:51:04+00:00

Really sorry for the extremely stupid title, but if I know what it is,

  • 0

Really sorry for the extremely stupid title, but if I know what it is, I wouldn’t write here (:

def some_decorator( func ):
    # ..

class A:
    @some_decorator
    def func():
        pass
    @func.some_decorator    # this one here - func.some_decorator ?
    def func():
        pass

some_decorator decorates func – that’s OK. But what is func.some_decorator and how some_decorator becomes a member ( or something else ? ) of func?

P.S. I’m 90% sure, that there’s such question here (as this seems something basic), but I don’t know how to search it. If there’s a exact duplicate, I’ll delete this question.


Note : It’s not typo, nor accident, that both member functions are named func. The decorator is for overloading: the question is related to Decorating method (class methods overloading)

  • 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-05-22T11:51:05+00:00Added an answer on May 22, 2026 at 11:51 am

    Remember that the function definition with decorator is equivalent to this:

    def func():
        pass
    func = some_decorator(func)
    

    So in the following lines, func doesn’t refer to the function you defined but to what the decorator turned it into. Also note that decorators can return any object, not just functions. So some_decorator returns an object with a method (it’s unfortunate that the names some_decorator and func are reused in the example – it’s confusing, but doesn’t change anything about the concept) that is itself a decorator. As the expression after the @ is evaluated first, you still have a reference to the first decorator’s method after you defined another plain function func. That decorator is applied to this new function. The full example is then equivalent to this:

    class A:
        def func():
            pass
        func = some_decorator(func)
    
        _decorator = func.some_decorator
        def func():
            pass
        func = _decorator(func)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry i really didn't know how to phrase the question any better but here
Sorry if this sounds like a really stupid question, but I need to make
Sorry but this is really confusing me and I know the answer is staring
I really didnt know what to put to the title so sorry about that.
Sorry the title is fuzzy, but I really coudln't come up with a fitting
I'm extremely sorry to post such an embarrassingly newbish question, but I haven't mucked
This might be extremely trivial, and if so I apologise, but I'm getting really
really sorry about being totally thick today but I have forgotten how to do
Sorry this is probably a really silly question but I am developing a WPF
sorry for lamer question, but I really could not found subject. I have a

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.