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 7519111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:50:56+00:00 2026-05-30T01:50:56+00:00

this may seem a little odd, but it would make for a convenient way

  • 0

this may seem a little odd, but it would make for a convenient way for me to finish a bit of code.

Because Python methods are objects themselves, could a method have a method of its own? That is, if I wanted to do the following (ignoring syntax):

def methodCaller(someArgs, methodB):
    # some stuff here . . .
    variableWithAGoodName = methodB()
    jonSkeet = methodB.methodC(variableWithAGoodName)
    return jonSkeet

Would it be possible? My guess is no, but if methods are just objects, shouldn’t it be possible somehow?

Thank you so much!

EDIT: I think as has been posted, I am looking for a high-order function.

My question is somewhat academic as I know I could reorganize my code to do this manner of thing totally differently. But, as it is, I am experimenting with Python to learn at least its basics. I haven’t tried this yet, but as I am unfamiliar with Python, it might be possible, just not with this syntax.

Another EDIT: I attempted to be funny with my naming but it made the question unclear. For that I apologize. Here is a better example:

def MethodA(MethodB):
    # MethodB is passed as a parameter but is also a method.
    # MethodB has a method of its own, somehow, because it is technically still
    # an object.
    MethodB.MethodC() #Let's pretend it returns nothing here.
    # Can this happen?
  • 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-30T01:50:58+00:00Added an answer on May 30, 2026 at 1:50 am

    Yes and no. Obviously they can have attributes assigned to them which work similarly to methods. Further, functions come with methods already attached- for example, the __call__ method, which is called with the function.

    However, to add a method to an object, what would you typically do? Subclass the object’s class, and add the method. However, if you try to subclass function

    imports types
    class F(types.FunctionType):
        pass
    

    you’ll get this error

    type 'function' is not an acceptable base type
    

    If you want to make a “callable” object, that can have methods and use inheritance, try something like this.

    class MyCallable(object):
        def __init__(self):
            self.message = "Look ma, I got called!"
    
        def __call__(self, *args, **kwargs):
            self.print_message()
    
        def print_message(self):
            print(self.message)
    
    
    class CallableChild(object):
        def __call__(self, *args, **kwargs):
            super(CallableChild, self).__call__(*args, **kwargs)
            print "...as a child, too!"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This may seem a little upside down faced, but what I want to be
This may seem like a daft question, but i was wondering about how to
This may seem like a somewhat contrived example, but I'm left scratching my head.
This may seem like a dumb question, but can an app build with c#
This may seem to be a IT question, but most IT people I asked
This may seem like a simple question but i am getting an error when
This may seem really silly to you, I admit, but when discussing the Model-View-ViewModel
This may seem like a stupid question, but what message do i send to
This may seem like a rudimentary request, but I can't seem to get it

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.