Jackson wrote:
> Maric Michaud wrote the following on 2006-08-14 01:26:
> > In [28]: class Animal(object) :
> >: _types = {}
> >:
> >:
> >
> > In [29]: class Worker(object) :
> >: def work(self) : print 'hard'
> >:
> >:
> >
> [snip]
> > What
Jackson wrote:
> Thanks for the reply.
>
> danielx wrote the following on 2006-08-13 19:49:
> > Is your declaration of ABC supposed to have some_super as one of the
> > base classes? Your constructor has some_super as a parameter. What is
> > this supposed to mean in light of the declaration for AB
John Machin wrote the following on 2006-08-14 01:45:
> Here are a couple of thoughts that *might* help:
>
> (1) mix-in i.e. a class can have multiple base classes:
>
> class AntWorker(Animal, Worker):
>
> (2) you can create classes on the fly using the 3-argument form of the
> built-in type() fu
Maric Michaud wrote the following on 2006-08-14 01:26:
> In [28]: class Animal(object) :
>: _types = {}
>:
>:
>
> In [29]: class Worker(object) :
>: def work(self) : print 'hard'
>:
>:
>
[snip]
> What you are trying to achieve is more common
Jackson wrote:
> I have 4 classes:
>
> Lion(Animal):
> Ant(Animal):
> Bee(Animal):
> Human(Animal):
>
> which are all subclasses of some superclass called Animal. Now I want
> to define an occupation. For example, Worker. A worker can exist as any
> of the 4 classes above. Their constructors ar
Le lundi 14 août 2006 09:33, Jackson a écrit :
> Now I realize this would drive a programmer crazy...because a Lion might
> have a roar() method whereas a Human might have a holler() method. But
> so long as the user knew which argument they passed in, it shouldn't be
> too difficult to keep track
Thanks for the reply.
danielx wrote the following on 2006-08-13 19:49:
> Is your declaration of ABC supposed to have some_super as one of the
> base classes? Your constructor has some_super as a parameter. What is
> this supposed to mean in light of the declaration for ABC?
Indeed, my goal is to
Is your declaration of ABC supposed to have some_super as one of the
base classes? Your constructor has some_super as a parameter. What is
this supposed to mean in light of the declaration for ABC?
If you are trying to customize the base class of ABC by passing an
argument to the constructor of AB
I want a class that will determine its base class by the argument passed
in. What I am about to write _does_not_work_, but it shows what I am
trying to do.
class ABC(some_super):
def __init__(self,some_super):
some_super.__init__(self)
if some_super == list: