(tokens, local_dict, global_dict)
return result
Converts floats into ``Rational``. Run AFTER ``auto_number``.
Converts floats into ``Rational``. Run AFTER ``auto_number``.
Converts floats into Rational . Run AFTER auto_number .
def rationalize(tokens, local_dict, global_dict):
    """Converts floats into ``Rational``. Run AFTER ``auto_number``."""
    result = []
    passed_float = False
    for toknum, tokval in tokens:
        if toknum == NAME:
            if tokval == 'Float':
                passed_float = True
                tokval = 'Rational'
            result.append((toknum, tokval))
        elif passed_float == True and toknum == NUMBER:
            passed_float = False
            result.append((STRING, tokval))
        else:
            result.append((toknum, tokval))

    return result
def rationalize ( tokens , local_dict , global_dict ) : result = [ ] passed_float = False for toknum , tokval in tokens : if toknum == NAME : if tokval == 'Float' : passed_float = True tokval = 'Rational' result . append ( ( toknum , tokval ) ) elif passed_float == True and toknum == NUMBER : passed_float = False result . append ( ( STRING , tokval ) ) else : result . append ( ( toknum , tokval ) ) return result