Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Spreading a class over multiple files Date: Sun, 5 Jun 2016 13:59:22 -0400 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de p6s8876CjGWlu1Db9Jnh4wp3Wfxj57M3rGUpscD11Tkg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'definitions.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subclass': 0.09; 'subject:files': 0.09; 'jan': 0.11; 'files.': 0.13; 'dislike': 0.16; 'idlelib': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:class': 0.16; 'toolbar': 0.16; 'wrote:': 0.16; 'differ': 0.18; 'gui': 0.18; 'class,': 0.22; 'trying': 0.22; 'programming': 0.22; 'am,': 0.23; 'tables': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'switch': 0.27; '(e.g.,': 0.27; 'reflect': 0.27; 'structure,': 0.29; 'such.': 0.29; 'classes': 0.30; 'class.': 0.30; 'primary': 0.31; 'table': 0.32; 'point': 0.33; 'options': 0.33; 'class': 0.33; 'idle': 0.33; 'interaction': 0.33; 'similar': 0.33; 'file': 0.34; 'instance': 0.35; 'requiring': 0.35; 'sometimes': 0.35; 'but': 0.36; 'actions': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'received:org': 0.37; 'spread': 0.37; 'things': 0.38; 'application': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'entire': 0.61; 'provide': 0.61; 'needs,': 0.63; 'received:96': 0.63; 'actions,': 0.84; 'subject:over': 0.84; 'tkinter,': 0.84; 'window,': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109522 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 refactored. > 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