why * is not like unquote (scheme)
Alex Martelli
aleax at aleax.it
Thu Mar 20 07:10:49 EST 2003
Peter Hansen wrote:
> Amir Hadar wrote:
>>
>> I'me tring to create a factory function that create a class as follow:
>>
>> def CreatePreviewFrame(*addins):
>> class tmp(cPreviewFrame,*addins):
>> pass
>> return tmp
,,,
> Maybe this is a rare case where you'll need to use exec to
> get the job done right.
No! Module new is what you need:
import new
def CreatePreviewFrame(*addins):
return new.classobj( 'tmp', (cPreviewFrame)+addins, {} )
Alex
More information about the Python-list
mailing list