Spreading a class over multiple files

Peter Otten __peter__ at web.de
Sun Jun 5 03:40:19 EDT 2016


Mark Summerfield wrote:

> Sometimes I want to spread a class over multiple files.
> 
> 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.

In other words, a God Class

http://c2.com/cgi/wiki?GodClass

> My question is -- are there nicer/better ways to achieve this?

Use composition.




More information about the Python-list mailing list