Re: [Python-ideas] [Python-Dev] What if replacing items in a dictionary returns the new dictionary?

May 5, 2011
5:19 p.m.
2011/5/5 Giuseppe Ottaviano <giuott@gmail.com>:
You're right, I would need to do more work to get it to mimic the underlying object. I think I will stick with Oleg's suggestion to subclass dict for now; it's great for unit tests. Thanks for the idea, though. class ReplaceableDict(dict): def replace(self, **kwargs): 'Works for replacing string-based keys' return dict(self.items() + kwargs.items())
5067
Age (days ago)
5067
Last active (days ago)
0 comments
1 participants
participants (1)
-
Roy Hyunjin Han