A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-April/111130.html below:

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

[Python-Dev] What if replacing items in a dictionary returns the new dictionary? [Python-Dev] What if replacing items in a dictionary returns the new dictionary?Roy Hyunjin Han starsareblueandfaraway at gmail.com
Fri Apr 29 17:05:35 CEST 2011
>   You can implement this in your own subclass of dict, no?

Yes, I just thought it would be convenient to have in the language
itself, but the responses to my post seem to indicate that [not
returning the updated object] is an intended language feature for
mutable types like dict or list.

class ReplaceableDict(dict):
    def replace(self, **kw):
        'Works for replacing string-based keys'
        return dict(self.items() + kw.items())
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4