David Wyde

Python dict quiz

What’s wrong with the following Python statement? How do you undo the damage?

dict = {123: 'abc'}

Answer: it clobbers the built-in dict type with a dictionary instance!

You can restore the original state in a few ways, including:

dict = {}.__class__
dict = type({})
dict = __builtins__.dict
dict = (lambda:0).func_globals.__class__