why * is not like unquote (scheme)

Peter Hansen peter at engcorp.com
Thu Mar 20 08:43:10 EST 2003


Alex Martelli wrote:
> 
> 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, {} )

Ah, thank you.  I've used only "module" from that module, based on
some recipe, so I've never actually looked in it in... 

Time to take a tour, methinks. :-)

-Peter




More information about the Python-list mailing list