Skip to content

Instantly share code, notes, and snippets.

@richmondwang
Created March 31, 2017 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richmondwang/7e4704c585af7c41f23dcbe790ec2cfb to your computer and use it in GitHub Desktop.
Save richmondwang/7e4704c585af7c41f23dcbe790ec2cfb to your computer and use it in GitHub Desktop.
Creates a dict whose top-level keys are always evaluated to str.
class StringedDict(dict):
def __setitem__(self, key, value):
super().__setitem__(str(key), value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment