def if_not_null(obj, alt):
    """ Returns 'obj' if it's not None, 'alt' otherwise. """

    if obj is None:
        if callable(alt):
            return alt()
        else:
            return alt

    return obj