Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self, *args, **kwargs):
call = Call('__call__',
BinaryOp('__getattr__', MetaArg("_"), self.name),
*args,
**kwargs
)
return self.to_copy(name = call)
def __getattr__(self, x):
# temporary hack working around ipython pretty.py printing
#if x == "__class__": return Symbolic
return Symbolic(BinaryOp(
"__getattr__",
self.__source,
strip_symbolic(x)
))
def needs_paren(self, x):
if isinstance(x, BinaryOp):
sub_lvl = BINARY_LEVELS[x.func]
level = BINARY_LEVELS[self.func]
if sub_lvl != 0 and sub_lvl > level:
return True
return False
def _binary_op(self, x):
if left_assoc:
node = BinaryOp(op_name, strip_symbolic(self), strip_symbolic(x))
else:
node = BinaryOp(op_name, strip_symbolic(x), strip_symbolic(self))
return Symbolic(node, ready_to_call = True)
return _binary_op
def __getitem__(self, x):
return Symbolic(BinaryOp(
"__getitem__",
self.__source,
slice_to_call(x),
),
ready_to_call = True)