Skip to content

Instantly share code, notes, and snippets.

@Atlas48
Last active September 18, 2022 11:06
Show Gist options
  • Save Atlas48/ae27ab05f703730fd4f4f69b44674695 to your computer and use it in GitHub Desktop.
Save Atlas48/ae27ab05f703730fd4f4f69b44674695 to your computer and use it in GitHub Desktop.
a bunch of python operators as functions; and then some
# a bunch of python operators as functions; and then some.
def add(x,y):
return x+y
def sub(x,y):
return x-y
def mul(x,y):
return x*y
def div(x,y):
return x/y
def pow(x,y):
return x**y
def mod(x,y):
return x%y
def ddiv(x,y):
return x//y
def vdiv(x,y):
return x//y, x%y
def eq(x,y):
return x==y
def ne(x,y):
return x!=y
def gt(x,y):
return x>y
def lt(x,y):
return x<y
def ge(x,y):
return x>=y
def le(x,y):
return x<=y
def get(x,y):
return x[y]
def bor(x,y):
return x|y
def band(x,y):
return x&y
def bnot(x):
return ~x
def bnor(x,y):
return ~x|~y
def bnand(x,y):
return ~x&~y
def bxor(x,y):
return x^y
def rshift(x,y):
return x>>y
def lshift(x,y):
return x<<y
def lor(x,y):
return x or y
def land(x,y):
return x and y
def lnot(x):
return not x
def lnor(x,y):
return not x or not y
def lnand(x,y):
return not x and not y
#def lxor(x,y):
# return (not x != not y) and (x or y)
def inv(x,y):
return x in y
def ninv(x,y):
return x not in y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment