On Sat, May 11, 2019 at 4:06 AM Jeff > I'd much rather have some kind of explicit wrapping or cast into their Python type: I had imagined the wrapped object would identify and behave as exactly that Python type (or ABC), however, it would be a *proxy* to the original.
The ABCs are already defined — if you want to make a wrapper proxy object, you implement the ABC you want to emulate. Now that I’m thinking about it more, this really covers most use cases: if you want your object to be converted to a dict by passing it to dict(), then implement the iteration protocol, returning key-value pairs that you want. This would work fine for dataclasses, and SimpleNamespaces, if one wanted to implement that. The only problem here is if you want to use the standard iteration protocol for something different -- I can't image what that would be. Sure, on the general case, maybe, but for a class that has a "natural" use case for dictifying, how else would you want to iterate over it?? -CHB >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/