Kaydet (Commit) 101651c1 authored tarafından Jeremy Hylton's avatar Jeremy Hylton

flesh out __all__

remove debugging code in if __debug__:

add get_children() method on SymbolTable
üst 26fabb00
...@@ -8,7 +8,8 @@ from _symtable import USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM, \ ...@@ -8,7 +8,8 @@ from _symtable import USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM, \
import weakref import weakref
__all__ = ["symtable", "SymbolTable", "newSymbolTable"] __all__ = ["symtable", "SymbolTable", "newSymbolTable", "Class",
"Function", "Symbol"]
def symtable(code, filename, compile_type): def symtable(code, filename, compile_type):
raw = _symtable.symtable(code, filename, compile_type) raw = _symtable.symtable(code, filename, compile_type)
...@@ -117,6 +118,10 @@ class SymbolTable: ...@@ -117,6 +118,10 @@ class SymbolTable:
for st in self._table.children for st in self._table.children
if st.name == name] if st.name == name]
def get_children(self):
return [newSymbolTable(st, self._filename)
for st in self._table.children]
class Function(SymbolTable): class Function(SymbolTable):
# Default values for instance variables # Default values for instance variables
...@@ -236,19 +241,6 @@ class Symbol: ...@@ -236,19 +241,6 @@ class Symbol:
raise ValueError, "name is bound to multiple namespaces" raise ValueError, "name is bound to multiple namespaces"
return self.__namespaces[0] return self.__namespaces[0]
if __debug__:
class Foo:
version = 1
class Foo:
version = 2
class Foo:
version = 3
def execfunc(x):
exec x in y
if __name__ == "__main__": if __name__ == "__main__":
import os, sys import os, sys
src = open(sys.argv[0]).read() src = open(sys.argv[0]).read()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment