def _replace_booleans(tok):
 (toknum, tokval) = tok
 if (toknum == tokenize.OP):
  if (tokval == '&'):
   return (tokenize.NAME, 'and')
  elif (tokval == '|'):
   return (tokenize.NAME, 'or')
  return (toknum, tokval)
 return (toknum, tokval)

def _replace_booleans ( tok ) : ( toknum , tokval ) = tok if ( toknum == tokenize . OP ) : if ( tokval == '&' ) : return ( tokenize . NAME , 'and' ) elif ( tokval == '|' ) : return ( tokenize . NAME , 'or' ) return ( toknum , tokval ) return ( toknum , tokval )
replace & with and and | with or so that bitwise precedence is changed to boolean precedence .