Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #send #operator #parameter #python
ADD COMMENT
Topic
Name
1+3 =