[Tutor] __getattribute__ instead of Mixing in and Mixing out classes in python

Tomaz Bevec tomazbevec at yahoo.com
Fri Aug 1 12:25:26 CEST 2008

Thanks for your suggestion, Kent.  I've looked into it a little bit and I think its probably the right way to go.  

--- On Thu, 7/31/08, Kent Johnson <kent37 at tds.net> wrote:

> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Mixing in and Mixing out classes in python
> To: tomazbevec at yahoo.com
> Cc: "Tutor Python" <tutor at python.org>
> Date: Thursday, July 31, 2008, 5:29 PM
> On Thu, Jul 31, 2008 at 8:09 PM, Tomaz Bevec
> <tomazbevec at yahoo.com> wrote:
> > Thanks for your reply Alan,
> >
> > I am partially asking out of interest, but I also have
> a potential application.
> >
> > I'm working on a simulation of cellular growth
> patterns (basically cell instances interacting
> stochastically on a lattice).  Anyway, there are many
> different cell "behaviors" that I have to
> simulate, and cells can potentially gain and lose these
> "behaviors" over the course of the simulation.  It
> would be too much to put every behavior function in the cell
> class, so I'm writing each behavior as a mixin and
> mixing it in (and initializing it) when necessary or when
> biological function is gained by the cells.
> Perhaps you could keep the behaviors in a dictionary? You
> could
> override __getattr__() in the cell class to look up
> attributes whose
> names start with 'behavior' in the dict.
> Kent


More information about the Tutor mailing list