def trycast(new_type, value, default=None):
    """
    Attempt to cast `value` as `new_type` or `default` if conversion fails
    """
    try:
        default = new_type(value)
    finally:
        return default