1 changed files with 14 additions and 0 deletions
@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*- |
||||
from __future__ import unicode_literals |
||||
# Erik Stein <code@classlibrary.net>, 2017 |
||||
|
||||
|
||||
def firstof(iterable, default=None): |
||||
""" |
||||
Returns the first value which is neither empty nor None. |
||||
|
||||
""" |
||||
for value in iterable: |
||||
if value: |
||||
return value |
||||
return default |
Loading…
Reference in new issue