Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-24 Thread Joe Strout
On Nov 24, 2008, at 11:10 AM, Matimus wrote: I wrote this a while ago. I sort of regret it though. Mixins could (and I will argue should) be avoided most of the time by delegating to other objects with less functionality. Utilizing many mixin classes tends to just make gigantic classes. This is

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-24 Thread Matimus
On Nov 21, 2:11 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I have a function that takes a reference to a class, and then   > instantiates that class (and then does several other things with the   > new instance).  This is easy enough: > >     item = cls(self, **itemArgs) > > where "cls" is the cla

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-23 Thread Rafe
On Nov 22, 9:02 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 21 Nov 2008 15:11:20 -0700, Joe Strout wrote: > > I have a function that takes a reference to a class, > > Hmmm... how do you do that from Python code? The simplest way I can think > of is to extract the nam

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-22 Thread George Sakkis
On Nov 22, 9:32 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: > > >> I have a function that takes a reference to a class, > > > Hmmm... how do you do that from Python code? The simplest way I can   > > think > > of is to extract the name of the clas

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-22 Thread Steven D'Aprano
On Sat, 22 Nov 2008 07:32:07 -0700, Joe Strout wrote: > On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: > >>> I have a function that takes a reference to a class, >> >> Hmmm... how do you do that from Python code? The simplest way I can >> think >> of is to extract the name of the class, and

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-22 Thread Arnaud Delobelle
Joe Strout <[EMAIL PROTECTED]> writes: > On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: > >>> I have a function that takes a reference to a class, >> >> Hmmm... how do you do that from Python code? The simplest way I can >> think >> of is to extract the name of the class, and then pass the na

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-22 Thread Joe Strout
On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: I have a function that takes a reference to a class, Hmmm... how do you do that from Python code? The simplest way I can think of is to extract the name of the class, and then pass the name as a reference to the class, and hope it hasn't b

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Steven D'Aprano
On Fri, 21 Nov 2008 15:11:20 -0700, Joe Strout wrote: > I have a function that takes a reference to a class, Hmmm... how do you do that from Python code? The simplest way I can think of is to extract the name of the class, and then pass the name as a reference to the class, and hope it hasn't

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Steve Holden
Joe Strout wrote: > On Nov 21, 2008, at 6:06 PM, Ned Deily wrote: > >>> Where would I find documentation on this nifty function? >> >> Where built-in functions are documented, the Python Library Reference: >> >> > > Perfect, thank you. (O

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 6:06 PM, Ned Deily wrote: Where would I find documentation on this nifty function? Where built-in functions are documented, the Python Library Reference: Perfect, thank you. (Odd that the index entry for type() d

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Ned Deily
In article <[EMAIL PROTECTED]>, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 21, 2008, at 3:30 PM, Arnaud Delobelle wrote: > > Of course it's possible: use type(name, bases, dict). > Thanks, I never knew about that form of type(). Neither does the > 2.5.2 reference manual, whose only index en

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 3:30 PM, Arnaud Delobelle wrote: Of course it's possible: use type(name, bases, dict). Thanks, I never knew about that form of type(). Neither does the 2.5.2 reference manual, whose only index entry for the type() function is

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread George Sakkis
On Nov 21, 5:11 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I have a function that takes a reference to a class, and then   > instantiates that class (and then does several other things with the   > new instance).  This is easy enough: > >     item = cls(self, **itemArgs) > > where "cls" is the cla

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Arnaud Delobelle
Joe Strout <[EMAIL PROTECTED]> writes: > I have a function that takes a reference to a class, and then > instantiates that class (and then does several other things with the > new instance). This is easy enough: > >item = cls(self, **itemArgs) > > where "cls" is the class reference, and itemA

how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Joe Strout
I have a function that takes a reference to a class, and then instantiates that class (and then does several other things with the new instance). This is easy enough: item = cls(self, **itemArgs) where "cls" is the class reference, and itemArgs is obviously a set of keyword arguments f