I'm trying to design a custom min/max function that will always filter out every None from the inputs and if there is nothing else than None, it will also return None. I have found several answers that were partial to my question on how to create an ideal function that can handle absolutely anything. Same as the original min/max functions.
This is what I have created so far:
def min_null(q, *args):
if isinstance(q, Iterable):
return min(filter(lambda x: x is not None, q)) if any(q) else None
else:
return min_null([q, *args])
can you see any way this could fail? Or how it could be improved?
I will be glad to any feedback :)