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

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
helps identifying a rational number from a float value by using a continued fraction .