Answers for "send operator by parameter python"

0

send operator by parameter python

import operator

# '>': operator.gt
# '<': operator.lt,
# '>=': operator.ge,
# '<=': operator.le,
# '=': operator.eq

get_truth(1.0, operator.gt, 0.0)

...

def get_truth(inp, relate, cut):    
    return relate(inp, cut)
    # you don't actually need an if statement here
Posted by: Guest on September-11-2020

Python Answers by Framework

Browse Popular Code Answers by Language