1 Aug 2008 02:09
Re: Mixing in and Mixing out classes in python
Tomaz Bevec <tomazbevec <at> yahoo.com>
2008-08-01 00:09:51 GMT
2008-08-01 00:09:51 GMT
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. In addition some of the behaviors would be too big (as in lines of code) if they were implemented in one function so splitting functionality up in my mixin class makes it conceptually easier for me. Also the behaviors sometimes need access to the internals of the cell class. After I mixin a class every method that starts with the word 'behavior.*' in that class is called when I update the simulation. All of my mixins inherit from "object" only. So far my approach is working well, but I don't have a clean way for cells to lose functionality. Hence my question about mixin out. I tried to just delete the 'behavior.*' functions with the del operator (like for an attribute) but it didn't work. I have however thought of a number of ways to work around this, and per your suggestion I think I'll just try something else, but if you have any idea on how to dynamically mix out I'd be glad to here it. Thanks, Tomaz --- On Thu, 7/31/08, Alan Gauld <alan.gauld <at> btinternet.com> wrote: > From: Alan Gauld <alan.gauld <at> btinternet.com> > Subject: Re: [Tutor] Mixing in and Mixing out classes in python(Continue reading)
RSS Feed