Open akva opened 5 years ago
So we basically need to implement a view-wrapper that applies a function to each value, but otherwise behaves like a view? There is nothing like this in the stdlib I think.
This project does it correctly afaict: https://github.com/aio-libs/multidict/blob/master/multidict/_multidict_py.py
WebOb gets it wrong as well btw: https://github.com/Pylons/webob/blob/master/src/webob/multidict.py#L318
Another option would be to simply not support dict
protocol. From my personal perspective MultiDict
has a pretty narrow use case, namely to support FormsDict
. And to handle web forms one doesn't need the whole richness of the dict
. Would make the implementation much simpler. But that's my two cents.
https://github.com/bottlepy/bottle/blob/9fb3b05846b33e508545a26e424785e151d02323/bottle.py#L2112
Assuming MultiDict supports
dict
protocol (which docstring suggests it does - ".., but behaves exactly like a normal dict.."),.values
implementation is not correct. The returned object should be a view which, among other things, supportslen
. See https://docs.python.org/3/library/stdtypes.html?#dict-views