Python: Pass inequality as string in dict for evaluation
I need to pass inequalities to a function for evaluation within the function. Is there a way to evaluation the inequality if passed as a string? Or must I pass a representation of the inequality and use if/else statements to generate the sign? senderle Your question is a little vague, but it sounds like you want to evaluate a string containing an expression (such as x > 5 ). Rather than doing that, which is unnecessarily complex, and potentially a security hazard, just define a function, either in the conventional way or using lambda. def gt5(x): return x > 5 or gt5 = lambda x: x > 5 These are