Re: Class hierarchy problem

2013-08-06 Thread Ben Finney
Terry Reedy writes: > 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 Phy

Re: Class hierarchy problem

2013-08-06 Thread Terry Reedy
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 Sp

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 4:36 PM, 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 sho

Re: Class hierarchy problem

2013-08-06 Thread Jordi Riera
Are you using a db for that? Django models would handle that pretty easily: class Species(models.Model): name = models.CharField() class Genus(models.Model): name = models.CharField() species = models.ManyToManyField( Species, related_name = 'genus_species' ) then you

Re: Class hierarchy problem

2013-08-06 Thread Joe Junior
On Tue, Aug 6, 2013 at 12:36 PM, BrJohan wrote: > On 06/08/2013 16:02, Chris Angelico wrote: > >>> 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'

Re: Class hierarchy problem

2013-08-06 Thread BrJohan
On 06/08/2013 16:02, Chris Angelico wrote: 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 'corr

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 2:58 PM, BrJohan wrote: > On 06/08/2013 11:30, Chris Angelico wrote: >> >> On Tue, Aug 6, 2013 at 10:10 AM, BrJohan wrote: >>> >>> Now, I want to create instances of the correct subclasstype as decided by >>> the common baseclass, like this: >>> >>> i = Sup(args_allowing_th

Re: Class hierarchy problem

2013-08-06 Thread Steven D'Aprano
On Tue, 06 Aug 2013 11:10:17 +0200, BrJohan wrote: > I'm in need of help to solve this Python (ver. 3.3) problem: > > I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, > SubC,...), each of which is inheriting from a chain of superclasses with > a common baseclass(Sup) on top. (So far

Re: Class hierarchy problem

2013-08-06 Thread Peter Otten
BrJohan wrote: > I'm in need of help to solve this Python (ver. 3.3) problem: > > I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, > SubC,...), each of which is inheriting from a chain of superclasses with > a common baseclass(Sup) on top. (So far, no problem) > > Now, I want to cr

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 10:10 AM, BrJohan 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)

Class hierarchy problem

2013-08-06 Thread BrJohan
I'm in need of help to solve this Python (ver. 3.3) problem: I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, SubC,...), each of which is inheriting from a chain of superclasses with a common baseclass(Sup) on top. (So far, no problem) Now, I want to create instances of the corr