Search code examples
pythonrinfix-operator

What is python's not? A special function type?


In R, ! is really an infix operator `!`, so statements like

Map(`!`,c(T,F,F))

are totally valid. Is there a way to access the first order object underlying not in Python? I have been googling with no success.


Solution

  • Python has the operator module, which includes a operator.not_() function:

    import operator
    
    map(operator.not_, (True, False, False))
    

    not itself is one of the boolean operators.