Kent Johnson kent37 at tds.net
Thu Feb 21 00:38:44 CET 2008

Tiger12506 wrote:

> Hehehe, did you try it Kent?

Obviously not :-)

> Which is not what I expected!
> Until I realized that you are missing the % sign in between the print string 
> and the tuple of values to interpolate

Blame that one on Michael, I copied from him :-)

> Then it returns this:
> varname: __builtins__ type: <type 'module'>
> Traceback (most recent call last):
>   File "C:\Documents and Settings\Jacob\Desktop\diction.py", line 1, in 
> <module>
>     for name, value in locals().iteritems():
> RuntimeError: dictionary changed size during iteration
> The .copy() is necessary. 

Ok. Or use locals().items() which implicitly copies by making a list of 
key, value pairs.

Though I suspect a robust solution will involve inspecting the stack 
frame passed to a sys.settrace() callback, not looking at locals() 


More information about the Tutor mailing list