Skip to content

zimscraperlib.misc

Miscelaneous utils

Functions:

  • first

    Return the first non-None value from *args; fallback to an empty string.

first

first(*args: T | None, default: T = '') -> T

Return the first non-None value from *args; fallback to an empty string.

Source code in src/zimscraperlib/misc.py
4
5
6
def first[T](*args: T | None, default: T = "") -> T:
    """Return the first non-None value from *args; fallback to an empty string."""
    return next((item for item in args if item is not None), default)