1

I was wondering whether anybody had come across a tool that can have a stab at depicting the control flow of a Python application - for instance, identifying the entry point(s) to a project, and identifying what code units are called from it.

As a more crude version, something which just maps the hierarchy of module imports would be handy. That gives you a lower resolution version of the above.

PS: I know that such a tools is not likely to provide results good enough for documentation purposes - I just want something to point me in the right direction, rather than trawling through the code with a clean sheet of paper...

  • 1
    Somewhat related : Visualize call graphs for Python – Mawg says reinstate Monica Jan 9 at 10:43
  • @MawgsaysreinstateMonica Very similar - i was just searching for different terminology :-( – Mike Sadler Jan 9 at 11:22
  • 1
    I hope that one of these gets an answer, as I would like to see it too :-) DoxyGen seems like a god way to go. I have used it for decades now, both privately & professionally & highly recommend it, if you don't already know it – Mawg says reinstate Monica Jan 9 at 11:28
  • 1
    I've used Doxygen for many years, but I hadn't realised that it had a caller graph functionality. – Mike Sadler Jan 9 at 12:56
0

I feel slightly guilty here for just capitalising on @MawgsaysreinstateMonica 's comments, which gives most of the answer, but I thought I'd just formalise it for another reader's benefit.

  1. Install Doxygen.
  2. Install Graphviz, and add its 'bin' directory
  3. Run up Doxywizard, and select the "Call graphs" and "Called by graphs" options (these are unticked by default)

This produces perfectly adequate call graphs, although they seem to get confused by Python's

if __main__:
   pass

clause. I just commented it out while producing the diagrams.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.