Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Understanding (and tracing) complex Python programs
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
np_123




PostPosted: Tue Oct 11, 2016 1:29 pm   Post subject: Understanding (and tracing) complex Python programs

Suppose you've got a decent sized python program, say ~60K LOC. The code isn't the cleanest, and documentation is minimal. It's got a GUI (uses Tkinter).
What's a good way of tracing the execution, or overall just figuring out how it works?
I mean, just diving into the code or manually tracing it can only get me so far, and with GUI and also with Python being dynamically typed (and unlike Java where you declare the type when you first define a variable), it can make understanding unfamiliar code a real hassle, especially if the code isn't very self-descriptive.



*I'm surprised the python tutorials forum/section here is kinda empty-looking. Might check for topics that aren't covered and write a couple myself
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed Oct 12, 2016 7:35 am   Post subject: RE:Understanding (and tracing) complex Python programs

I'd identify the major functions and objects first to get a feel for the overall structure of the program. Determine what those functions do and figure out how they work. If they call a function or object that isn't obvious in its role or implementation, take a look inside that function to determine what it does and how it works. Continue recursively until the work is understood.
np_123




PostPosted: Wed Oct 12, 2016 2:44 pm   Post subject: RE:Understanding (and tracing) complex Python programs

true, makes sense.

i've since found out that there are tools like pyreverse that can be used to generate UML and dependency diagrams...but that works on a module-by-module basis.
do you by chance know of any automated tools that can do similar decomposition program-wide? it'd be great if there's an easy-ish way for me to figure out if the modules have a hierarchy of sorts
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: