I have written this helper function. I want to know if there is an even better approach, considering that I do not want to add a dependency to any additional module.def _isobjectInList(lst, name, criteria='startswith'):     Find item in the list  starting or ending with name passed.        :param lst: list of items/ objects        :type lst: list        :param name: name starting or ending with.        :param name: string        :param criteria: function of string obect whether startswith or endswith        :param criteria: built-in method of str object         return [itemfound for itemfound in lst if getattr(itemfound, criteria)(name)]
Finding an item name starting or ending with from a list
python
There are a few issues with the documentation:The second entry for each parameter should be :type for all three parameters;The criteria parameter (which should really be named criterion) isn't a built-in method, it's the name of a method; andThe description of the function only applies if the third parameter is 'startswith' or 'endswith', but that isn't actually a limitation the function has (similarly, see the description of the name parameter).  Also the name isn't quite right (even allowing for PEP-8 violation); given the name, I'd expect a bool back, not a list. Given how trivial the function is, though, I would probably just inline the list comprehension where needed. It doesn't handle multiple positional arguments or any keyword arguments to the method, but I'm not sure implementing that would be worthwhile. 