invoke()
Calls a method on each item in an array
Implementation
Uses getattr to find and call methods
Example
results = UniCoreFW.invoke(['hello', 'world'], 'upper')
Expected output: ['HELLO', 'WORLD']
Source Code
def invoke(array, func_name, *args):
return [
getattr(item, func_name, None)(*args) if hasattr(item, func_name) else None
for item in array
]