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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:38:41+00:00 2026-05-16T02:38:41+00:00

What are peoples’ opinions on using the __call__ . I’ve only very rarely seen

  • 0

What are peoples’ opinions on using the __call__. I’ve only very rarely seen it used, but I think it’s a very handy tool to use when you know that a class is going to be used for some default behaviour.

  • 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-16T02:38:42+00:00Added an answer on May 16, 2026 at 2:38 am

    I think your intuition is about right.

    Historically, callable objects (or what I’ve sometimes heard called “functors”) have been used in the OO world to simulate closures. In C++ they’re frequently indispensable.

    However, __call__ has quite a bit of competition in the Python world:

    • A regular named method, whose behavior can sometimes be a lot more easily deduced from the name. Can convert to a bound method, which can be called like a function.
    • A closure, obtained by returning a function that’s defined in a nested block.
    • A lambda, which is a limited but quick way of making a closure.
    • Generators and coroutines, whose bodies hold accumulated state much like a functor can.

    I’d say the time to use __call__ is when you’re not better served by one of the options above. Check the following criteria, perhaps:

    • Your object has state.
    • There is a clear “primary” behavior for your class that’s kind of silly to name. E.g. if you find yourself writing run() or doStuff() or go() or the ever-popular and ever-redundant doRun(), you may have a candidate.
    • Your object has state that exceeds what would be expected of a generator function.
    • Your object wraps, emulates, or abstracts the concept of a function.
    • Your object has other auxilliary methods that conceptually belong with your primary behavior.

    One example I like is UI command objects. Designed so that their primary task is to execute the comnand, but with extra methods to control their display as a menu item, for example, this seems to me to be the sort of thing you’d still want a callable object for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are peoples opinions on jira studio? i.e. using the hosted product for a
I was just wondering what are peoples opinions on using axis for webservice development?
Just a quick one: what are peoples thoughts on using Action delegates for public
Silly question really but just was wondering about other peoples naming conventions for DAL
Obviously one should sanitise sessions when the're being created, but what are peoples thoughts
I can find some articles on how to use them but I can't seem
I've been solving a few problems on SPOJ.pl using python 3.1.2 and some peoples
So, this is a pretty simple sounding question, but I'm interested in other peoples
I would like to hear opinions or peoples experiences regarding Rel . Is it
Putting peoples opinions about garbage collection aside are there any deadlocking issues with the

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.