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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:57:12+00:00 2026-06-09T08:57:12+00:00

I want to get information about the callers of a specific function in python.

  • 0

I want to get information about the callers of a specific function in python. For example:

class SomeClass():
    def __init__(self, x):
        self.x = x
    def caller(self):
        return special_func(self.x)

def special_func(x):
    print "My caller is the 'caller' function in an 'SomeClass' class."

Is it possible with 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-09T08:57:14+00:00Added an answer on June 9, 2026 at 8:57 am

    Yes, the sys._getframe() function let’s you retrieve frames from the current execution stack, which you can then inspect with the methods and documentation found in the inspect module; you’ll be looking for specific locals in the f_locals attribute, as well as for the f_code information:

    import sys
    def special_func(x):
        callingframe = sys._getframe(1)
        print 'My caller is the %r function in a %r class' % (
            callingframe.f_code.co_name, 
            callingframe.f_locals['self'].__class__.__name__)
    

    Note that you’ll need to take some care to detect what kind of information you find in each frame.

    sys._getframe() returns a frame object, you can chain through the whole stack by following the f_back reference on each. Or you can use the inspect.stack() function to produce a lists of frames with additional information.

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

Sidebar

Related Questions

I want to get the information about subviews property of class UIView : objc_property_t
I want to get information about blocked and dropped calls. When you call someone
I am developing an app related to ActivityManager. I want to get information about
I want to get the information about the the machine configuration i.e like ip
I'm writting a Software to get some Information about Server and i just want
Is there a field_load() function equivalent to node_load() ? I want to get information
I want to be able to get information about the selected item in the
In my forum that I am building, I want to get information about users
So, I know I can use dir() to get information about class members etc.
I want to get information about selected text when I press F1. But always

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.