Reputation: 3479
A good example of this is: http://github.com/tav/tweetapp/blob/a711404f2935c3689457c61e073105c1756b62af/app/root.py
In Visual Studio (ASP.net C#) where I come from, the classes are usually split into separate files + I can set break points to understand the code level.
If I run a program like this, do I just do "system.out" to print out where in the code I am in?
I read through this https://stackoverflow.com/questions/246546/good-techniques-for-understanding-someone-elses-code which was quite helpful.
Upvotes: 1
Views: 411
Reputation: 37490
If you install Eclipse and PyDev you can set breakpoints in the same way you can in visual studio.
Failing that, printing out information at cucial points is often a good way to see what's going on. I quite often add in debug information that way and leave it in the code but disabled until I change a variable. I find this often helps if you break the code and need to go back and take another look at what's going on. Better still, send your debug information to a logging class and you can start to use the output in unit tests... you do test your code right? ;)
Upvotes: 0
Reputation: 6911
You've run into a pretty specific case of code that will be hard to understand. They probably did that for the convenience of having all the code in one file.
I would recommend letting epydoc have a pass at it. It will create HTML documentation of the program. This will show you the class structure and you can even build charts of which functions call which other functions.
http://epydoc.sourceforge.net/manual-usage.html
Your other options are to break it into multiple files yourself (which I think will be tedious and not of much benefit)
Upvotes: 3