Representation of python code ?

showellshowell at gmail.com showellshowell at gmail.com
Mon Sep 15 10:06:19 EDT 2008


On Sep 15, 4:38 am, Maric Michaud <ma... at aristote.info> wrote:
> Le Sunday 14 September 2008 15:44:03 Barak, Ron, vous avez écrit :
>
> > Hi Guys,
> > Is there a script/application, which gets as input python code, and
> > produces a (graphic) representation of the inter-relationships between its
> > classes/functions ? Bye,
>

If you can't find anything that's already packaged up and polished,
one possibility is to use the parser and/or compiler.ast modules in
Python to analyze your code, then produce something that graphviz can
consume.

Graphviz is something really nice to have in your bag of tricks,
anyway.

  http://www.graphviz.org/

> None I know of. Not saying that it would be unfeasible, but it would be a hard
> job, given the fact that most of relationships are purely dynamic.
>
> How such an application would find the relationship (composition) between A
> and B without executing this code ?
>

I'm not sure this is the best counterexample.  You can see statically
that A potentially creates an instance of the B class.

> class A :
>     def __init__(self) :
>          self._b = B()
>
> class B : pass
>



More information about the Python-list mailing list