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 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

I am sorry for the title but I really do not know how to
Really stupid question, sorry, but I can't find it on google (I'm sure it's
I'm really sorry. This must seem like an incredibly stupid question, but unless I
Im really sorry for asking such a newby question but I dont know what
I'm really sorry if this come across as stupid but i've searched everywhere but
I m really sorry for unclear question title but I am a bit confused
I'm really sorry to have to ask this, but I clearly don't understand something
Sorry for unclear subject but i really don't understand where problem. I use a
Sorry if this is a really basic question but it's been really getting to
A really php newbie here, sorry if the question is too simple. I’m following

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.