A
Alan G Isaac
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
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