Dave Parker wrote [sorry folks, I'm tired, so this is halfway to a rant :-( ]
it's ok. I was wandering around the office kicking things and looking dazed a couple of weeks ago when I finally delved into this stuff.
I'm not happy that I now know what TemplateDict is - I really wish I hadn't had to go there, but now that I'm there I have a much better understanding of why it is impossible to get information out of it; it has "do you have this key" and "get the value of this key" and absolutely nothing else.
The problem is that it's implemented as a multimapping. To do keys(), items(), &c you'd have to walk the multimapping and search each object. I guess you could simply do something like this (untested, written from just looking at the MultiMapping.c code. Probably could be implemented far more easily...) t = templatedictobj l = [] while 1: try: l.append(t.pop()) except IndexError: break # l now has the dictionaries from the namespace stack l.reverse() d = {} for i in l: d.update(i) t.push(i) print d.items(), d.keys(), d.values() this code just pops all the namespace objects off the multimapping, stores them in a list, merges them together and pushes them back onto the multimapping. it's horribly inefficient. and probably buggy. :) Anthony