0

I want to define a function something like that;

def compVar(variable1 , comparator, variable2):
   condition = ( variable1.Value 'comparator' variable2.Value)

I am using a SW Simulation tool and it has it's own library, there is a condition variable which gives a boolean output corresponds to PASS or FAIL according to True or False. So i want to use user input as comparator operator but couldn't figure out how to write comparator as operator in condition. Tool is using Python 2.

Random Davis
  • 5,623
  • 3
  • 13
  • 24
python101
  • 11
  • 3
  • How can i compare 3 variables? But 3rd one should be optional, something like below wouldn't work because i should enter 3rd variable all the time. `import operator def comp(var1, comp, var2,var3): ops = {'>': operator.gt, '=': operator.ge, '<=': operator.le, '==': operator.eq} return ops[comp](var1, var2)&ops[comp](var2,var3) ` – python101 Nov 16 '21 at 17:42

0 Answers0