def tryint(str):
    """
    Returns an integer if `str` can be represented as one.
    
    :param str: String to check.
    :type str: string
    :returns: int(str) if str can be cast to an int, else str.
    :rtype: int or str
    """
    
    try:
        return int(str)
    except:
        return str