New submission from HaiYun Yan <lyricco...@gmail.com>: use "as" for block scope support just like mozilla javascript "let" extension https://developer.mozilla.org/en/new_in_javascript_1.7#Block_scope_with_let_%28Merge_into_let_Statement%29
usage: as_clause(as_declare): "as" NAME as_stmt: NAME "as" test as_expr: "(" expr "as" NAME ")" expr var declare by as_clause is alive in <suite> only eg: <NAME "f" binding saved>with open(...) as f<NAME "f" bind to HEAPObj>: ... <NAME "f" binding restored> the same rule to "except E as e: " spec: from socket import AF_INET as IPv4 <IPv4 bind to socket.AF_INET slot> IPv4 = None assert socket.AF_INET == None var in as_stmt is alive in current indentation eg: for i in range(10): <NAME "t" binding saved> t as f()+1 <NAME "t" bind to f()+1> ... <NAME "t" binding restored> var in as_expr is alive in sub expr only eg: t = None x = (2+3 as t) t**2 assert t == None ane x == 25 Suggestion: new opcode ENTER_BLOCK #depth #varslots ---------- components: Interpreter Core messages: 141076 nosy: lyricconch priority: normal severity: normal status: open title: use "as" for block scope support type: feature request _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12635> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com