Spreading a class over multiple files

Terry Reedy tjreedy at udel.edu
Sun Jun 5 13:59:22 EDT 2016

On 6/5/2016 2:55 AM, Mark Summerfield wrote:
> Sometimes I want to spread a class over multiple files.

My experience with trying to work with two do-all classes in idlelib has 
engendered a dislike for such.  It is hard to find things in a 
kitchen-sink class.  To switch IDLE from being a multi-window 
application to having multiple panes in a single window, both must be 

> My primary use case is when I create a "Model" class to reflect an
> entire SQL database. I want a model instance to provide a single
> point of access to the database, but the database has many tables
> each requiring its own methods since they differ in their structure,
> purpose, validation needs, etc.

I would consider a master database ('Model') class, a base table class, 
and a subclass class for each table or group of similar tables.

> A secondary use case is when I create "MainWindow" classes in GUI
> programming and have lots of methods to reflect all the actions
> (e.g., menu options and toolbar actions, plus interaction with the
> main widget(s)).

With tk and tkinter, at least, implementation functions do not have to 
be in the same file as the menu or toolbar definitions.

Terry Jan Reedy

More information about the Python-list mailing list