New submission from Matias G <guija...@esrf.fr>:
Hi, This is more a question/proposal than a real issue. I apologize in advance if this has already been debated or if it is not relevant. I noticed `setdefault` method of mutable mapping objects is returning the default value as passed in the call, when applicable, without passing through `__getitem__`. I think it would be more "symmetric" if it would return the default value set by `__setitem__` via `__getitem__`. This would handle the case of a custom MutableMapping defining a custom behaviour of `__setitem__` and `__getitem__`. Of course, in my case finally I overloaded `setdefault` to do this, but it might be worth in general, at least for the MutableMapping class. Thanks, Matias. ---------- messages: 375984 nosy: guijarro priority: normal severity: normal status: open title: MutableMapping ".setdefault()" to return default value via __getitem__ type: enhancement versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41647> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com