Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread George Sakkis
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > I've just found this: > > [quote] > A mixin class is a parent class that is inherited from - but not as > a means of specialization. Typically, the mixin will export services to a > child class, but no semantics will be implied about the child "being

Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread barnesc
>So mixins are just a sub-class [pun intended] of sub-classing? > >I've just found this: > >[quote] >A mixin class is a parent class that is inherited from - but not as >a means of specialization. Typically, the mixin will export services to a >child class, but no semantics will be implied about t

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Michele Simionato
Paul Rubin wrote: > Yeah, I wonder though how much of that is a result of Python's > cavalier approach to multiple inheritance. Does that happen much in > CLOS? In Java because of multiple interfaces? I've studied Flavors a > little and mix-ins were used in some extensive ways, but maybe > progr

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Thu, 06 Oct 2005 21:03:33 -0700, barnesc wrote: >> I added some recipes to the Python Cookbook: >> >> - listmixin >> >>Use ListMixin to create custom list classes from a small subset of >>list methods: >> >>http://aspn.activestate.com

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Steven D'Aprano
On Fri, 07 Oct 2005 05:11:00 -0700, Michele Simionato wrote: > Well, suppose you have a class MyObject and you want to add to it some > methods to make its instances into a database. You could put these > methods into another class called Storable (the mixin class). > Then you can mix MyObject wit

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Paul Rubin
"Michele Simionato" <[EMAIL PROTECTED]> writes: > Once in a time, I thought mixins where a good idea; now I don't think > so since they are too easily abused (see Zope 2) and as a consequence > you get spaghetti-inheritance, where you have objects with methods > inherited from everywhere. So be ver

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > That looks great. Now, if only I understood mixins: what are they, and > what they are for, and in particular, how they differ from mere > subclassing. I'm not sure what you mean by "mere subclassing" so maybe there is no difference. Mixins are sort o

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Michele Simionato
Well, suppose you have a class MyObject and you want to add to it some methods to make its instances into a database. You could put these methods into another class called Storable (the mixin class). Then you can mix MyObject with Storable and get what you want, a class StorableObject inheriting bo

Re: Python recipes: list mixin, improved timeit, etc

2005-10-07 Thread Steven D'Aprano
On Thu, 06 Oct 2005 21:03:33 -0700, barnesc wrote: > I added some recipes to the Python Cookbook: > > - listmixin > >Use ListMixin to create custom list classes from a small subset of >list methods: > >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440656 That looks great

Python recipes: list mixin, improved timeit, etc

2005-10-06 Thread barnesc
I added some recipes to the Python Cookbook: - listmixin Use ListMixin to create custom list classes from a small subset of list methods: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440656 - pytime Improves on timeit by allowing you to time a function directly (no