def try_parse(value, parser, default=None):
    """Try to parse value using parser, returning default if the parse fails"""
    try:
        return parser(value)
    except (TypeError, ValueError):
        return default
