> Im not sure if the dict(other) cast is the best way to go about it. Maybe this would work?
Yeah, I was imagining something like that... I used the cast for brevity in my reply but that probably wasn't helpful.
Note that for __or__, we probably want to check the type of the argument (for either dict or ChainMap, or maybe just Mapping), to keep it from working on an iterable of key-value pairs.
> I guess we need a __ror__ as well, in case there's some other mapping that doesn't implement __or__:
Agreed. Again, we can check for Mapping here to assure success for the copy() move.
> As a refinement, __or__ and __ror__ should perhaps check whether the operation can possibly succeed and return NotImplemented instead of raising? (Based on the type of other only, not its contents.)
Yup, see above. I think a check for Mapping should be fine. |