Any tools to print source code call hierarchy

S

Scott Chapman

I'm sure I'm not using the conventional names for this tool, more of a
cross-referencer?. I couldn't find it on Google, I think for this reason.

I need a tool that will go through a python module (ClientForm in this case)
and allow me to specify a starting module to parse and tell me what all it
uses.

What I'm trying to do is to take ClientForm apart enough to pull out just the
html form parsing code in it and use it elsewhere. It would be MUCH easier
when approaching someone elses code if I could see what all functions are
called by a given function, etc.

TIA,
Scott
 
L

Lothar Scholz

Scott Chapman said:
I'm sure I'm not using the conventional names for this tool, more of a
cross-referencer?. I couldn't find it on Google, I think for this reason.

I need a tool that will go through a python module (ClientForm in this case)
and allow me to specify a starting module to parse and tell me what all it
uses.

What I'm trying to do is to take ClientForm apart enough to pull out just the
html form parsing code in it and use it elsewhere. It would be MUCH easier
when approaching someone elses code if I could see what all functions are
called by a given function, etc.

Because python is a dynamical typed non image language there is no
tool that can do this and there never will be any (at least one that
is not using heuristics or sampled data from previous runs).
 
S

Simon Burton

On Sat, 06 Sep 2003 16:34:21 -0700, Lothar Scholz wrote:

....
Because python is a dynamical typed non image language there is no
tool that can do this and there never will be any (at least one that
is not using heuristics or sampled data from previous runs).

hmmm... I think (some) static analysis may be possible. The main
thing to exclude is eval/exec but even then, yes you're right, some
programs would just have to be run to find out what they do.

I remember reading some interesting things here:
http://www.python.org/doc/essays/cp4e.html

In particular:
"Cormac Flanagan and Matthias Felleisen.
Componential Set-Based Analysis.
ACM Transactions of Programming Languages and Systems"

Simon.
 
M

Michael Peuser

Simon Burton said:
On Sat, 06 Sep 2003 16:34:21 -0700, Lothar Scholz wrote:

...

hmmm... I think (some) static analysis may be possible. The main
thing to exclude is eval/exec but even then, yes you're right, some
programs would just have to be run to find out what they do.

It it is not only eval/exec. You can create methods dynamically. And static
analysis will already run into trouble when you import moduls dynamically.

What I do very often is "rename" a procedure, e.g. in cases as:
def pVersion1(): ...
def pVersion2(): ...

if....
p=pVersion1

This is not even tricky.
Kindly
Michael P
 
L

Lothar Scholz

Simon Burton said:
hmmm... I think (some) static analysis may be possible. The main
thing to exclude is eval/exec but even then, yes you're right, some
programs would just have to be run to find out what they do.

Whats with code like:

if foo:
def myfunc():
... do something
else:
def myfunc():
... calling your_func()


A Language where the program calling hierarchie depends on runtime
calculations is not able to provide good refactoring tools or static
flow analysis. This is the huge difference to a language like
Smalltalk where we live in an image.

And if you say that this is a hack, then you are making a big mistake,
look at currently used code and you will find so much uses of this
style (or even worse styles) that it seems to be a common paradigm.
 
B

Bengt Richter

Whats with code like:

if foo:
def myfunc():
... do something
else:
def myfunc():
... calling your_func()


A Language where the program calling hierarchie depends on runtime
calculations is not able to provide good refactoring tools or static
flow analysis. This is the huge difference to a language like
Smalltalk where we live in an image.

And if you say that this is a hack, then you are making a big mistake,
look at currently used code and you will find so much uses of this
style (or even worse styles) that it seems to be a common paradigm.

Which only begins to hint at what is possible with metaclasses ;-)

Regards,
Bengt Richter
 
J

John J. Lee

Scott Chapman said:
I need a tool that will go through a python module (ClientForm in this case)
and allow me to specify a starting module to parse and tell me what all it
uses.

What I'm trying to do is to take ClientForm apart enough to pull out just the
html form parsing code in it and use it elsewhere. It would be MUCH easier
when approaching someone elses code if I could see what all functions are
called by a given function, etc.

In the absence of that, you could try just asking me. :)

_FormParser is it, really. What exactly did you want to do?


As for the general question: I only glanced at the other replies, but
have you tried etags? Or for something in a single source file, as in
this case, why not just incremental search or other simple editor
commands? It's true a bit of knowledge of common dynamic Python
idioms is valuable here, though.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top