def _convert(value, to_type, default=None):
    """Convert value to to_type, returns default if fails."""
    try:
        return default if value is None else to_type(value)
    except ValueError:
        # If value could not be converted
        return default
def _convert(value, to_type, default=None):
    
    try:
        return default if value is None else to_type(value)
    except ValueError:
        
        return default
def _convert ( value , to_type , default = None ) : try : return default if value is None else to_type ( value ) except ValueError : # If value could not be converted return default
Convert value to to_type, returns default if fails.
Convert value to to_type returns default if fails .