def compare_func( relopstr ):
    """ "< 3"  ->  the function  x -> (x < "3")  NB str "3" not num 3
    """
    # (could lambda x: (x < 3) if isnum(x)  else (x < "3")
    # but then version: > 0.1  is num compare,
    #          version: > 0.1.0  str

    relop, s = _relop_re.match( relopstr ) .groups()
    if relop == "=":  relop = "=="
    s = s.rstrip() .strip( "\"" )
    cmptext = "lambda x: x %s \"%s\"" % (relop, s)
                # e.g.   x < "3" 
    if Test:
        print >>sys.stderr, "compare_func: %s" % cmptext
    return eval( cmptext )  # try ?
 "< 3"  ->  the function  x -> (x < "3")  NB str "3" not num 3
    
recipes/Python/576741_uniform_matcher_re_pattern__re__func__dict_/recipe-576741.py