MCPcopy Create free account
hub / github.com/ActiveState/code / call

Method call

recipes/Python/87370_Collection/recipe-87370.py:20–25  ·  view source on GitHub ↗

return the result of calling 'attr' for each of our elements

(self, attr, *args, **kwds)

Source from the content-addressed store, hash-verified

18 return Collection([getattr(x, attr) for x in self if hasattr(x, attr)])
19
20 def call(self, attr, *args, **kwds):
21 """return the result of calling 'attr' for each of our elements"""
22 attrs = self.get(attr)
23 return Collection([x(*args, **kwds)
24 for x in attrs
25 if callable(x)])
26
27if __name__ == "__main__":
28 import time

Callers 1

recipe-87370.pyFile · 0.45

Calls 4

getMethod · 0.95
CollectionClass · 0.70
xClass · 0.50
callableFunction · 0.50

Tested by

no test coverage detected