namespaces and eval

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Fri May 16 17:47:02 EDT 2008


On 16 mai, 23:23, dave.g1... at gmail.com wrote:
> Thanks for the responses.  I'm well aware that the function can be
> passed in the parameters, passing in the functino as an arg defeats
> the purpose of what I'm going after.

Why so ?

> @ Arnaud - Nice. I'm not sure what the performance of mine vs. yours,
> but a perfunctory glance looks like we're doing the close to the same
> thing.  Maybe one advanage to doing it wrap(x).foo().... is that you
> can pass in other parameters to foo.

I may be wrong (if so please pardon my lack of intelligence and/or
provide a couple use case), but it looks like you're trying to
reinvent partial application.

from functools import partial
def foo(x, y):
  return x + y

pfoo = partial(foo, 2)
print pfoo(42)

Don't know if this helps...



More information about the Python-list mailing list