def _tup(t): if isinstance(t, str): return self._new(_ast.Name, t, _ast.Store()) elif isinstance(t, tuple): elts = [_tup(x) for x in t] return self._new(_ast.Tuple, elts, _ast.Store()) else: raise NotImplemented
def visit_AugAssign(self, node): target = self.visit(node.node) # Because it's AugAssign target can't be list nor tuple # so we only have to change context of one node target.ctx = _ast.Store() op = self.aug_operators[node.op]() return self._new(_ast.AugAssign, target, op, self.visit(node.expr))
def get_ctx(self, flags): if flags == 'OP_DELETE': return _ast.Del() elif flags == 'OP_APPLY': return _ast.Load() elif flags == 'OP_ASSIGN': return _ast.Store() else: # FIXME Exception here assert False, repr(flags)