Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'tree': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; 'itself.': 0.14; 'assigns': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; '(or': 0.24; 'possibly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'related': 0.29; 'said,': 0.30; 'class': 0.32; 'could': 0.34; 'knowledge': 0.35; 'earth': 0.36; 'instances': 0.36; 'possible': 0.36; 'should': 0.36; 'level': 0.37; 'implement': 0.38; 'generic': 0.38; 'to:addr :python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'kingdom': 0.61; 'received:173': 0.61; 'course': 0.61; 'such': 0.63; 'effectively': 0.66; 'received:fios.verizon.net': 0.84; 'subject:Class': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Class hierarchy problem Date: Tue, 06 Aug 2013 19:13:40 -0400 References: <520100F9.4010805@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375830834 news.xs4all.nl 15898 [2001:888:2000:d::a6]:51917 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52082 On 8/6/2013 11:36 AM, BrJohan wrote: > Consider a botanical classification system (somewhat analogous to my > 'problem' as it effectively is related to classification of entities): > > A Domain should know about its Kingdoms, > a Kingdom should know about its Phylums, > ... > a Genus should know about its Species. As some already said, 'a domain' is an instance of Domain (or possibly generic Taxon). We have on Earth one instance of 'Life'. > > Of course it is possible to implement such a decision tree as a > 'factory'. However, I would rather prefer to encapsulate those decisions > at the class level where they 'belong'. Each instance could have a .classify function that assigns instances to sub-instance. The master classifier function would only know how to use the .classify functions and have no specific content knowledge in itself. -- Terry Jan Reedy