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

Diagramming code

88 views
Skip to first unread message

hamilton

unread,
Jul 15, 2012, 9:26:52 PM7/15/12
to
Is there any software to help understand python code ?

Thanks

hamilton

Chris Rebert

unread,
Jul 15, 2012, 9:38:53 PM7/15/12
to hamilton, pytho...@python.org
On Sun, Jul 15, 2012 at 6:26 PM, hamilton <hami...@nothere.com> wrote:
> Subject: Diagramming code
>
> Is there any software to help understand python code ?

What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
diagrams? Module dependency diagrams? There are many different types
you could be referring to. Here's a relatively comprehensive list:
http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview

Regards,
Chris
--
UML: Kill it with fire!

hamilton

unread,
Jul 15, 2012, 9:57:29 PM7/15/12
to
OK then, let me ask, how do you guys learn/understand large projects ?

hamilton

Chris Rebert

unread,
Jul 15, 2012, 10:13:12 PM7/15/12
to hamilton, pytho...@python.org
In case you're responding to my trailing semi-satirical comment, let
me clarify: I was remarking on UML specifically, not software-related
diagrams in general.

Cheers,
Chris

Ulrich Eckhardt

unread,
Jul 16, 2012, 3:58:46 AM7/16/12
to
Am 16.07.2012 03:57, schrieb hamilton:
> OK then, let me ask, how do you guys learn/understand large projects ?

1. Use the program. This gives you an idea what features are there and a
bit how it could be structured.
2. Build the program, to see what is done to get the program running.
This should give you an idea what pieces there are and where they are
[from].
3. Read design documentation (which is too often outdated) which should
give you an idea what the intention of the project's structure is.
4. Read the code documentation (which is hopefully more up to date).
This should give you an idea about responsibilities within the code.
5. Read the code itself. This can also be done while single-stepping
through it with a debugger, just to see it run.

Of course there are also secondary resources like developers' and users'
mailinglists, websites, bugtrackers that provide information and help.

Sometimes, drawing a few diagrams from steps 3 and 4 to document
relationships between things is helpful. IMHO having a text describing
the relationships in prose is superior to that though. In particular a
diagram can't describe the rationale for something, you need prose for that.

HTH & YMMV

Uli

Joel Goldstick

unread,
Jul 16, 2012, 5:00:42 AM7/16/12
to Ulrich Eckhardt, pytho...@python.org
> --
> http://mail.python.org/mailman/listinfo/python-list

Do you know about pydoc? Its a great way to get a handle on your
modules. It doesn't make diagrams, but a synopsis of what is in the
module. It makes use of docstrings, for the module and each class and
function in the module.

--
Joel Goldstick

Sells, Fred

unread,
Jul 16, 2012, 1:02:13 PM7/16/12
to hamilton, pytho...@python.org
You leave many relevant questions unanswered.

1. Is the original developer/team available or have you been left with
the code and little or no doc's?

2. How big is big in terms of the number of files/modules in the
project?

3. Is there a reasonable structure to the project in terms of
directories and a meaningful hierarchy

4. Does the project currently work and you just have to maintain/enhance
it or was it "abandoned" by the original team in an unknown state and
you have to save a sinking ship?

5. Are you an experienced Python programmer or a beginner.

6. Is the original code "pythonic" (i.e. clean and simple with brief,
well organized methods) or do you have functions over 50 lines of code
with multiple nested control statements and meaningless variable names?

7. Is there any documentation that defines what it should do and how it
should do it. i.e. how do you know when it's working?

These issues are not really Python specific, but if you've been given a
"broken" project that has 200 poorly organized modules and little or no
documentation and no access to the original team, a good first step
would be to update your resume ;)

OK then, let me ask, how do you guys learn/understand large projects ?

hamilton

--
http://mail.python.org/mailman/listinfo/python-list

Message has been deleted

hamilton

unread,
Jul 16, 2012, 2:36:18 PM7/16/12
to

Thank you Fred.

I am new to python and am reviewing code I find online.

Some projects do have docs that spell out what its doing,
but many projects that I have download have just the code.

I have my own personal style to decypher C and C++ code.

But python is still foreign to me.

hamilton

Miki Tebeka

unread,
Jul 16, 2012, 3:47:40 PM7/16/12
to
> Is there any software to help understand python code ?
For module dependency you can try http://furius.ca/snakefood/

Andrea Crotti

unread,
Jul 16, 2012, 4:41:31 PM7/16/12
to hamilton, pytho...@python.org
Sometimes to get some nice graphs I use gprof2dot
(http://code.google.com/p/jrfonseca/wiki/Gprof2Dot)
or doxygen (http://www.stack.nl/~dimitri/doxygen/)

gprof2dot analyses the output of the profiling that you get running the
code through the python profiler,
doing for example:

python -m cProfile -o $STATS $FNAME $@
$GPROF2DOT -f pstats $STATS | dot -T$TYPE -o $OUT

doxygen is more useful for C++ but it's also able to infer a few things
(without running) from a python project..

Andrew Cooper

unread,
Jul 16, 2012, 6:24:08 PM7/16/12
to
+1 for doxygen.

Combined with http://code.foosel.org/doxypy , it is a fully featured
solution. I use it for all my projects, python and otherwise.

~Andrew

88888 Dihedral

unread,
Jul 17, 2012, 10:11:54 AM7/17/12
to comp.lan...@googlegroups.com, hamilton, pytho...@python.org
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道:
> On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;hami...@nothere.com&gt; wrote:
> &gt; Subject: Diagramming code
> &gt;
> &gt; Is there any software to help understand python code ?
>
> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
> diagrams? Module dependency diagrams? There are many different types
> you could be referring to. Here&#39;s a relatively comprehensive list:
> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
>
> Regards,
> Chris
> --
> UML: Kill it with fire!

OK, I'll classify OOP by (1) properties of instances of declared classes must be fixed such as those in C++ (2) An interpreter could be embedded in the run time for an object to evolve through time to accquire properties.


If the robot age was to be comming, what can we do now?

I think learning python is the high school
does help a lot for the United States in the future.

88888 Dihedral

unread,
Jul 17, 2012, 10:11:54 AM7/17/12
to hamilton, pytho...@python.org
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道:
> On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;hami...@nothere.com&gt; wrote:
> &gt; Subject: Diagramming code
> &gt;
> &gt; Is there any software to help understand python code ?
>
> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
> diagrams? Module dependency diagrams? There are many different types
> you could be referring to. Here&#39;s a relatively comprehensive list:
> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
>
> Regards,
> Chris
> --
> UML: Kill it with fire!

0 new messages