why * is not like unquote (scheme)

Michele Simionato mis6 at pitt.edu
Thu Mar 20 17:23:23 CET 2003


"Amir Hadar" <amir at clockwise3d.com> wrote in message news:<b5c8uj$s78$1 at news2.netvision.net.il>...
> Hi
> 
> I'me tring to create a factory function that create a class as follow:
> 
> def CreatePreviewFrame(*addins):
>     class tmp(cPreviewFrame,*addins):
>         pass
>     return tmp
> 
> I checked a simpler case:
> (1,2,*(3,4))
> and this is also syntax error.
> 
> but I can path parameters to a function as follow:
> 
> def f(a,b):
>      print a,b
> 
> l = ("a","b")
> f(*l)
> 
> So why doesn't it work in all cases?
> 
> Amir

Do you know that type can be used as a class factory with the syntax
type(name,tupleofbases,classdict) ?

>>> def classfactory(name,*bases,**kw):
...    return type(name,bases,kw)

Maybe this can help.

                                                     Michele




More information about the Python-list mailing list