Need to create module with virtual functions to mirror another module

Paul Keating keating at acm.org
Sat Dec 14 08:29:11 EST 2002


Thanks for the help.

I am pleased to say I had it very nearly right, but I couldn't get the
lambda expression to do what I wanted. I was trying to get the lambda
expression to be the call, rather than return the call, and it was being
evaluated only once, so all of the newstyle names ended up pointing at one
oldstyle function. So I thought I was barking up the wrong tree.

>> (if the test for which things should be wrapped is fixed).

I used callable()

"Martin v. Löwis" <martin at v.loewis.de> wrote in message
news:atf7i5$1ei$02$1 at news.t-online.com...
>
> Where is the problem? If the functions are in newstyle.__dict__, modules
> importing newstyle should find them easily.
>
> I would suspect that a loop like
>
> for name, obj in oldstyle.__dict__.items():
>    if obj is not a function: continue
>    globals()[name] = lambda args, func = obj: func(*args)
>
> should do (if the test for which things should be wrapped is fixed).
>
> Regards,
> Martin
>





More information about the Python-list mailing list