As a recurrent situation, I need to invoke the same method
on many instances.  Speed matters, but the solution should
be pure Python.  Is the following convenience function
a reasonable approach?

def apply2(itr, methodname, *args, **kwargs):
    f = operator.methodcaller(methodname, *args, **kwargs)
    for item in itr:
        f(item)

(Comment: in the case at hand, the methods return None.)

Thank you,
Alan Isaac


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to