Skip to content

Commit

Permalink
Added bitwise operations
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Apr 14, 2021
1 parent 8b4b377 commit 7afa3fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions simpleeval.py
Expand Up @@ -241,12 +241,15 @@ def safe_add(a, b): # pylint: disable=invalid-name

DEFAULT_OPERATORS = {ast.Add: safe_add, ast.Sub: op.sub, ast.Mult: safe_mult,
ast.Div: op.truediv, ast.FloorDiv: op.floordiv,
ast.BitXor: op.xor, ast.BitOr: op.or_, ast.BitAnd: op.and_, ast.BitAnd: op.and_,
ast.LShift: op.lshift, ast.RShift: op.rshift,
ast.Pow: safe_power, ast.Mod: op.mod,
ast.Eq: op.eq, ast.NotEq: op.ne,
ast.Gt: op.gt, ast.Lt: op.lt,
ast.GtE: op.ge, ast.LtE: op.le,
ast.Not: op.not_,
ast.USub: op.neg, ast.UAdd: op.pos,
ast.Invert: op.inv,
ast.In: lambda x, y: op.contains(y, x),
ast.NotIn: lambda x, y: not op.contains(y, x),
ast.Is: lambda x, y: x is y,
Expand Down

0 comments on commit 7afa3fd

Please sign in to comment.