[Tutor] Need to be pointed in the right direction for file organisation.

Alan Gauld alan.gauld at btinternet.com
Sat Jul 25 21:50:27 CEST 2009


"Mac Ryan" <quasipedia at gmail.com> wrote

> time). I was therefore thinking about separating the classes for each
> "tabbed window" in different files, under the impression that this would
> make the program faster / with a smaller memory footprint, as only the
> needed file will be loaded into memory 

The gains would be minimal, and its dcertainly not common practice. 
In fact having more modules loaded might even make performance 
worse! I'd certainly categorize that as premature optimisation!

> Another concern of mine was the readability of the source code, and I
> was wondering indeed if there was a "pythonic style" that was commonly
> understood as "the right one" 

Not for file organisation. There is the package concept so if 
you have a lot of related modules you could create a package 
structure, but most of Python's organisation guidelines tend to 
focus on maximising reuse rather than organizing the current 
project, in my experience at least.

>> - Build modules "bottom up" so that depenedencies tend to 
>>   go one way, with higher level modules importing lower level ones.
> 
> I'm not sure I got it completely, does this mean that the file structure
> should be a hint of how dependency works, 

No, just that you should try to keep low level functuions etc in 
separate files and have the higher level, more abstract modules 
import them. Rather than mixing low level, implementation 
dependant coded with more abstract - and therefore more portable
module code.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list