當前位置: 首頁>>代碼示例>>Python>>正文


Python consts.OP_ASSIGN屬性代碼示例

本文整理匯總了Python中compiler.consts.OP_ASSIGN屬性的典型用法代碼示例。如果您正苦於以下問題:Python consts.OP_ASSIGN屬性的具體用法?Python consts.OP_ASSIGN怎麽用?Python consts.OP_ASSIGN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在compiler.consts的用法示例。


在下文中一共展示了consts.OP_ASSIGN屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: expr_stmt

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def expr_stmt(self, nodelist):
        # augassign testlist | testlist ('=' testlist)*
        en = nodelist[-1]
        exprNode = self.lookup_node(en)(en[1:])
        if len(nodelist) == 1:
            return Discard(exprNode, lineno=exprNode.lineno)
        if nodelist[1][0] == token.EQUAL:
            nodesl = []
            for i in range(0, len(nodelist) - 2, 2):
                nodesl.append(self.com_assign(nodelist[i], OP_ASSIGN))
            return Assign(nodesl, exprNode, lineno=nodelist[1][2])
        else:
            lval = self.com_augassign(nodelist[0])
            op = self.com_augassign_op(nodelist[1])
            return AugAssign(lval, op[1], exprNode, lineno=op[2])
        raise WalkerError, "can't get here" 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:transformer.py

示例2: for_stmt

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def for_stmt(self, nodelist):
        # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]

        assignNode = self.com_assign(nodelist[1], OP_ASSIGN)
        listNode = self.com_node(nodelist[3])
        bodyNode = self.com_node(nodelist[5])

        if len(nodelist) > 8:
            elseNode = self.com_node(nodelist[8])
        else:
            elseNode = None

        return For(assignNode, listNode, bodyNode, elseNode,
                   lineno=nodelist[0][2]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:transformer.py

示例3: com_try_except_finally

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def com_try_except_finally(self, nodelist):
        # ('try' ':' suite
        #  ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite]
        #   | 'finally' ':' suite))

        if nodelist[3][0] == token.NAME:
            # first clause is a finally clause: only try-finally
            return TryFinally(self.com_node(nodelist[2]),
                              self.com_node(nodelist[5]),
                              lineno=nodelist[0][2])

        #tryexcept:  [TryNode, [except_clauses], elseNode)]
        clauses = []
        elseNode = None
        finallyNode = None
        for i in range(3, len(nodelist), 3):
            node = nodelist[i]
            if node[0] == symbol.except_clause:
                # except_clause: 'except' [expr [(',' | 'as') expr]] */
                if len(node) > 2:
                    expr1 = self.com_node(node[2])
                    if len(node) > 4:
                        expr2 = self.com_assign(node[4], OP_ASSIGN)
                    else:
                        expr2 = None
                else:
                    expr1 = expr2 = None
                clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))

            if node[0] == token.NAME:
                if node[1] == 'else':
                    elseNode = self.com_node(nodelist[i+2])
                elif node[1] == 'finally':
                    finallyNode = self.com_node(nodelist[i+2])
        try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
                               lineno=nodelist[0][2])
        if finallyNode:
            return TryFinally(try_except, finallyNode, lineno=nodelist[0][2])
        else:
            return try_except 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:42,代碼來源:transformer.py

示例4: com_with_item

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def com_with_item(self, nodelist, body, lineno):
        # with_item: test ['as' expr]
        if len(nodelist) == 4:
            var = self.com_assign(nodelist[3], OP_ASSIGN)
        else:
            var = None
        expr = self.com_node(nodelist[1])
        return With(expr, var, body, lineno=lineno) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:transformer.py

示例5: com_try_except_finally

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def com_try_except_finally(self, nodelist):
        # ('try' ':' suite
        #  ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite]
        #   | 'finally' ':' suite))

        if nodelist[3][0] == token.NAME:
            # first clause is a finally clause: only try-finally
            return TryFinally(self.com_node(nodelist[2]),
                              self.com_node(nodelist[5]),
                              lineno=nodelist[0][2])

        #tryexcept:  [TryNode, [except_clauses], elseNode)]
        clauses = []
        elseNode = None
        finallyNode = None
        for i in range(3, len(nodelist), 3):
            node = nodelist[i]
            if node[0] == symbol.except_clause:
                # except_clause: 'except' [expr [',' expr]] */
                if len(node) > 2:
                    expr1 = self.com_node(node[2])
                    if len(node) > 4:
                        expr2 = self.com_assign(node[4], OP_ASSIGN)
                    else:
                        expr2 = None
                else:
                    expr1 = expr2 = None
                clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))

            if node[0] == token.NAME:
                if node[1] == 'else':
                    elseNode = self.com_node(nodelist[i+2])
                elif node[1] == 'finally':
                    finallyNode = self.com_node(nodelist[i+2])
        try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
                               lineno=nodelist[0][2])
        if finallyNode:
            return TryFinally(try_except, finallyNode, lineno=nodelist[0][2])
        else:
            return try_except 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:42,代碼來源:transformer.py

示例6: com_with

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:11,代碼來源:transformer.py

示例7: com_list_comprehension

# 需要導入模塊: from compiler import consts [as 別名]
# 或者: from compiler.consts import OP_ASSIGN [as 別名]
def com_list_comprehension(self, expr, node):
            # list_iter: list_for | list_if
            # list_for: 'for' exprlist 'in' testlist [list_iter]
            # list_if: 'if' test [list_iter]

            # XXX should raise SyntaxError for assignment

            lineno = node[1][2]
            fors = []
            while node:
                t = node[1][1]
                if t == 'for':
                    assignNode = self.com_assign(node[2], OP_ASSIGN)
                    listNode = self.com_node(node[4])
                    newfor = ListCompFor(assignNode, listNode, [])
                    newfor.lineno = node[1][2]
                    fors.append(newfor)
                    if len(node) == 5:
                        node = None
                    else:
                        node = self.com_list_iter(node[5])
                elif t == 'if':
                    test = self.com_node(node[2])
                    newif = ListCompIf(test, lineno=node[1][2])
                    newfor.ifs.append(newif)
                    if len(node) == 3:
                        node = None
                    else:
                        node = self.com_list_iter(node[3])
                else:
                    raise SyntaxError, \
                          ("unexpected list comprehension element: %s %d"
                           % (node, lineno))
            return ListComp(expr, fors, lineno=lineno) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:36,代碼來源:transformer.py


注:本文中的compiler.consts.OP_ASSIGN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。