Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Any tools to print source code call hierarchy

1 view
Skip to first unread message

Scott Chapman

unread,
Sep 6, 2003, 2:33:53 PM9/6/03
to
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


Lothar Scholz

unread,
Sep 6, 2003, 7:34:21 PM9/6/03
to
Scott Chapman <scott...@mischko.com> wrote in message news:<mailman.1062873250...@python.org>...

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).

Simon Burton

unread,
Sep 6, 2003, 7:51:36 PM9/6/03
to
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.


Michael Peuser

unread,
Sep 7, 2003, 1:37:22 AM9/7/03
to

"Simon Burton" <sim...@webone.com.au> schrieb im Newsbeitrag
news:pan.2003.09.06....@webone.com.au...

> 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.

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

Lothar Scholz

unread,
Sep 7, 2003, 6:21:25 AM9/7/03
to
Simon Burton <sim...@webone.com.au> wrote in message news:<pan.2003.09.06....@webone.com.au>...

> 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.

Bengt Richter

unread,
Sep 7, 2003, 1:14:00 PM9/7/03
to

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

Regards,
Bengt Richter

Skip Montanaro

unread,
Sep 6, 2003, 6:08:57 PM9/6/03
to

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

This is not a trivial exercise to perform with Python because it is
dynamically typed. In many cases you don't know the type of an object until
runtime.

Skip

John J. Lee

unread,
Sep 7, 2003, 7:21:57 PM9/7/03
to
Scott Chapman <scott...@mischko.com> writes:
[...]

> 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

Tom

unread,
Sep 9, 2003, 12:25:06 AM9/9/03
to
Skip Montanaro <sk...@pobox.com> wrote in message news:<mailman.1062967091...@python.org>...

I wrote a tool called PySpy (see
http://members.rogers.com/qwavel/pyspy/) that presented call graph
information based on a runtime analysis of Python programs.

Unfortunately, it only works with Python v2.1. I hope to update it
when I get time.

I don't monitor this ng.

Tom.

0 new messages