mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
10 lines
374 B
Python
10 lines
374 B
Python
|
|
def first_non_null(*iterable):
|
|
'''
|
|
Returns the first element from the iterable which is not None.
|
|
If all the elements are 'None', 'None' is returned.
|
|
:param iterable: Iterable containing list of elements.
|
|
:return: First non-null element, or None if all elements are 'None'.
|
|
'''
|
|
return next((item for item in iterable if item is not None), None)
|