On Sat, 7 May 2005 01:06:31 +0200, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>James Stroud wrote:
>
>> I did this:
>>
>> py> class bob(object):
>> ... def __init__(self,**kwargs):
>> ... for fname,func in kwargs.items():
>> ... setattr(self, fname, lambda *args : func(*args))
>> ...
>
Thanks to both Scott and Fredrik.
James
On Friday 06 May 2005 04:22 pm, Scott David Daniels wrote:
> James Stroud wrote:
> > Hello All,
> >
> > I did this:
> >
> > py> class bob(object):
> > ... def __init__(self,**kwargs):
> > ... for fname,func in kwargs.items():
> > ... setattr(sel
James Stroud wrote:
> Hello All,
>
> I did this:
>
> py> class bob(object):
> ... def __init__(self,**kwargs):
> ... for fname,func in kwargs.items():
> ... setattr(self, fname, lambda *args : func(*args))
> ...
> py> def doit():
> ... print "wuzzup?"
> ...
> py> abob = bob(doit=doi
James Stroud wrote:
> I did this:
>
> py> class bob(object):
> ... def __init__(self,**kwargs):
> ... for fname,func in kwargs.items():
> ... setattr(self, fname, lambda *args : func(*args))
> ...
> py> def doit():
> ... print "wuzzup?"
> ...
> py> abob = bob(doit=doit)
> py>
> py> a
I think it is more clear to rephrase your code as:
-#!/usr/bin/env python
-class bob(object):
-def __init__(self,**kwargs):
-print kwargs
-for fname,func in kwargs.items():
-setattr(self, fname, lambda *args : func(*args))
-
-def doit():
-print "wuzzup?"
-
-
-abo
Hello All,
I did this:
py> class bob(object):
... def __init__(self,**kwargs):
... for fname,func in kwargs.items():
... setattr(self, fname, lambda *args : func(*args))
...
py> def doit():
... print "wuzzup?"
...
py> abob = bob(doit=doit)
py>
py> abob.doit()
wuzzup?
Much to my su