Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52042
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'tree': 0.05; 'responding': 0.07; '"right"': 0.16; 'created.': 0.16; 'factory': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'investigate': 0.16; 'nearest': 0.16; 'subclasses': 0.16; 'sup': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'aug': 0.22; 'subject:problem': 0.24; '(or': 0.24; 'class.': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'along': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; "skip:' 10": 0.31; 'node': 0.31; 'oversight': 0.31; 'way?': 0.31; 'class': 0.32; 'themselves': 0.32; 'alone': 0.33; 'knowledge': 0.35; 'classes': 0.35; 'common': 0.35; 'except': 0.35; 'one,': 0.35; 'received:google.com': 0.35; 'instances': 0.36; "i'll": 0.36; 'should': 0.36; 'so,': 0.37; 'handle': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'hope': 0.61; 'choose': 0.64; 'decided': 0.64; 'determine': 0.67; "'upper'": 0.84; 'itself?': 0.84; 'working,': 0.84; 'subject:Class': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QeR8ohfTxOlvikKjPOs/bQbzWhl51bOlbgHS2PpYPwk=; b=oL8jmU6zE+ArmgSRHDsTI+r1ozGjyss87VZpUa4HGhPt2TRa8+8e/9B13tKSsu+SER ow2HB3jmwzvsPRjVacwFE8/9BvHPVfd+xfA3TOXcUoFp8ll/sZiTEHxPtR+m8d6V9MWi BI6PEcaN5sUy6B5jvzyDPiT9b1uSmEMlUGMe5ZN8pp3QwtxOV/s2bjBXVcMvwJ5ilR5z SkFdBXPN/Oan05dUsOXVGVFI9IiTRB0y3WzG+ldSVjrwhQPHlkbRt/vQ2uImD4OIVoZ0 l1TfLzaQ45Y9Pg44eGO75G6Xv9CjRUUp5bdr+BEqFQQUnUS9JI9xtZ5LdBTROjPglIXa uzQA== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.94.78 with SMTP id da14mr354510vdb.28.1375797743497; Tue, 06 Aug 2013 07:02:23 -0700 (PDT) |
| In-Reply-To | <520100F9.4010805@gmail.com> |
| References | <ktqeho$f5i$1@news.albasani.net> <mailman.235.1375781442.1251.python-list@python.org> <520100F9.4010805@gmail.com> |
| Date | Tue, 6 Aug 2013 15:02:23 +0100 |
| Subject | Re: Class hierarchy problem |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.254.1375797746.1251.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375797746 news.xs4all.nl 15865 [2001:888:2000:d::a6]:46076 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52042 |
Show key headers only | View raw
On Tue, Aug 6, 2013 at 2:58 PM, BrJohan <brjohan@gmail.com> wrote: > On 06/08/2013 11:30, Chris Angelico wrote: >> >> On Tue, Aug 6, 2013 at 10:10 AM, BrJohan <brjohan@gmail.com> wrote: >>> >>> Now, I want to create instances of the correct subclasstype as decided by >>> the common baseclass, like this: >>> >>> i = Sup(args_allowing_the_baseclass_to_deduce_correct_subclass) >>> >>> where i can be of any class except Sup itself (as decided by Sup) >> >> >> Can you do this as a factory function instead of the class itself? >> Then all you need to do is call the appropriate class. >> >> ChrisA >> > > My classhierarchy is like a multilevel tree where each non-leaf node (class) > is given knowledge about its nearest subclasses and their 'capacities'. > > So, my idea is to let the 'upper' class recursively choose which of its > nearest subclasses is the 'correct' one, until approaching a 'leaf' class > from which the instance should be created. And, given my knowledge that a > solution along the lines of this idea has been designed and was working, I'm > still hopeful ... (or I'll have to investigate all those old backup-DVDs) [ responding on-list - I hope it was mere oversight that had this come privately to me alone ] This is code smell; this recursive search for the "right" class seems likely to be wrong. Can you have the classes perhaps register themselves in some way? On what basis is a superclass to determine that one of its subclasses should handle this request? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Class hierarchy problem BrJohan <brjohan@gmail.com> - 2013-08-06 11:10 +0200
Re: Class hierarchy problem Chris Angelico <rosuav@gmail.com> - 2013-08-06 10:30 +0100
Re: Class hierarchy problem Chris Angelico <rosuav@gmail.com> - 2013-08-06 15:02 +0100
Re: Class hierarchy problem BrJohan <brjohan@gmail.com> - 2013-08-06 17:36 +0200
Re: Class hierarchy problem Joe Junior <joe.fbs.junior@gmail.com> - 2013-08-06 13:23 -0300
Re: Class hierarchy problem Jordi Riera <kender.jr@gmail.com> - 2013-08-06 18:13 +0200
Re: Class hierarchy problem Chris Angelico <rosuav@gmail.com> - 2013-08-06 18:12 +0100
Re: Class hierarchy problem Terry Reedy <tjreedy@udel.edu> - 2013-08-06 19:13 -0400
Re: Class hierarchy problem Ben Finney <ben+python@benfinney.id.au> - 2013-08-07 11:58 +1000
Re: Class hierarchy problem Peter Otten <__peter__@web.de> - 2013-08-06 11:34 +0200
Re: Class hierarchy problem Steven D'Aprano <steve@pearwood.info> - 2013-08-06 09:36 +0000
pexpect, loading an entry field inq1ltd <inq1ltd@inqvista.com> - 2013-08-06 11:05 -0400
Re: pexpect, loading an entry field "Lakshmipathi.G" <lakshmipathi.g@gmail.com> - 2013-08-06 22:04 +0530
Re: pexpect, loading an entry field inq1ltd <inq1ltd@inqvista.com> - 2013-08-06 14:03 -0400
Re: pexpect, loading an entry field "Lakshmipathi.G" <lakshmipathi.g@gmail.com> - 2013-08-07 13:40 +0530
csiph-web