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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:34:00+00:00 2026-06-15T12:34:00+00:00

i have source code of a open source project in python, the project has

  • 0

i have source code of a open source project in python, the project has a module(python) and gui using the module the gui is written in qtpython , now while using the gui and preforming various actions in it is there any way that i can know what are the functions being called and from where something like a log and is there any way i can generate uml diagram of the source code so that i can understand it better and contribute to the project.version of python the project is using is 2.7

  • 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-15T12:34:01+00:00Added an answer on June 15, 2026 at 12:34 pm

    As mentioned in a comment, generating UML from Python is already discussed in this answer. (Keep in mind that Python doesn’t actually have to be UML-representable—but if it is, great.)

    As for seeing the flow of control at runtime, there are a few ways you could do this. One is by using profiling and/or debugging tools. But let’s look at the simplest possible way to log it, which is what you asked for:

    You can “log” anything at any time by just printing to the console. You will have to run the app from the command line instead of launching it GUI-style (and on a Mac, this means you have to run the executable/script directly, not any .app bundle that’s been built out of it), but then you’ve got your logging output—and you can use your shell (even Windows cmd) to redirect this to a file for later browsing, if you’d prefer. If this isn’t good enough for you, see the logging module built into the standard library.

    If you want to know where a function is being called from, you can log a stack trace every time the function gets called. This is a bit ugly, but it provides all the information you could ever want, and you can always write some code to parse the output later. The function traceback.print_stack does exactly that. (If you want to get more fancy, use other functions to extract the information, format if how you want, and log it how you want.)

    You do that by adding this line to every function you want to trace:

    traceback.print_stack()
    

    Another way to do this is to write a monkey-patcher and apply it to all the functions you care about:

    def tracify(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            traceback.print_stack()
            func(*args, **kwargs)
        return wrapper
    

    Now, in the main script, just do this:

    InterestingClass.interestingMethod = tracify(InterestingClass.interestingMethod)
    

    Now, every time InterestingClass.interestingMethod gets called, it will print out a stack trace. You don’t have to understand how tracify works. If you want to change what it does to the function, just replace the line traceback.print_stack() with whatever you want to do.

    So, what if you want to patch every “public” method in a class?

    for attr in dir(InterestingClass):
        if not attr.startswith('_'):
            method = getattr(InterestingClass, attr)
            if isinstance(method, instancemethod):
                setattr(InterestingClass, tracify(method))
    

    (This is for Python 2. Python 3 changes things up, making complicated cases much simpler, but trivial cases not quite as trivial.)

    What if you want to patch every public method of every class, and every free function, in a module? You can iterate over a module the same way, and check the type of each thing, just as you can with a class.

    You could also use the inspect module to do the hard stuff for you. But if you’re just learning Python, I think copying and pasting the dir code is much simpler than learning how to use inspect. Once you’re more comfortable with the language, come back and play with inspect to figure out why it all worked.

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

Sidebar

Related Questions

I have an open source project written in python , it has some Forms
I have an open source project containing both Python and C code. I'm wondering
I have been looking through some code on an open source project recently and
i have a code generator project i would like to offer like open source,
I am exploring the code of an open source project..The project has its own
I've been working on a project using python with OpenGL for a while now.
Warning: git novice here. I have downloaded the source code of an open-source project
I have been using an open source Java project and had to make some
I have built an open-source application from the source code. Unfortunately, the original executable
I have java source code in a text file. There has to be entered

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.