symtable module & globals

I've found the symtable module, which is quite nice. Unfortunately, I cannot find any documentation, and the module don't work as I expect: If the source looks like this: foo = 1 def fie(): print foo Calling is_global() for the "foo" name returns False (using the fie functions SymbolTable). With a method, is_global() returns true, though: foo = 1 class C: def fie(self): print foo Have I misunderstood something, or is this a bug? -- /Peter Åstrand <astrand@lysator.liu.se>

On Thu, 2004-02-12 at 15:41, Peter Åstrand wrote:
I've found the symtable module, which is quite nice. Unfortunately, I cannot find any documentation, and the module don't work as I expect:
You're very generous in complimenting an undocumented module that doesn't work as you expect <wink>. I think both things you report are bugs. Can you file a bug report and assign it to me? Jeremy

I've found the symtable module, which is quite nice. Unfortunately, I cannot find any documentation, and the module don't work as I expect:
When I run my program, which uses the symtable module, on Python 2.3, I get: -:0: SyntaxWarning: import * only allowed at module level -:0: SyntaxWarning: import * only allowed at module level -:0: SyntaxWarning: import * only allowed at module level -:0: SyntaxWarning: import * only allowed at module level In a way this is not very surprising, since I call symtable with: symtable.symtable(source, "foo", "exec") This is a big problem for me, since I need to inspect symtables on a module level. Would it be possible to make it possible for symtable to operate in a module context? Or is it safe to ignore these warnings? -- /Peter Åstrand <astrand@lysator.liu.se>
participants (3)
-
Jeremy Hylton
-
Peter Astrand
-
Peter Åstrand