def try_to_encode(value, callback=str):
    """Tries to encode a value by verifying existence of `_dynaconf_encode`"""
    try:
        return value._dynaconf_encode()
    except (AttributeError, TypeError):
        return callback(value)
Tries to encode a value by verifying existence of `_dynaconf_encode`
dynaconf/utils/parse_conf.py