def cast(s):
    '''
    Cast a basestring to a more appropriate type.
    Example::
        >>> from yaxil import cast
        >>> type(cast("999"))
        <type 'int'>
    
    :param s: String
    :type s: basestring
    :returns: Casted string
    :rtype: int|float|str
    '''
    if not isinstance(s, basestring):
        raise TypeError("argument must be a string")
    for test in [int, float, str]:
        try:
            return test(s)
        except ValueError:
            continue
    return str(s)