I completely agree that there is a problem to be solved here.
Unfortunately I don't think the Scalar ABC is the solution. I'm not
sure that there is a generic solution, since different applications will
have different ideas of what needs to be drilled down into.
E.g. a tuple representing coordinates (1, 2) might be treated as an
atomic value, rather than a collection.
Perhaps a useful partial solution would be to define a "String-like"
ABC, consisting of str, bytes, UserString, possibly even bytearray and
memoryview.
But given that (1) UserString is rarely used, and (2) its pretty easy to
simply say `isinstance(obj, (str, bytes))`, I'm not sure that it is
worth the effort of predefining it.
Speaking of UserString, does anyone know why it isn't registered as a
virtual subclass of str?
py> from collections import UserString
py> issubclass(UserString, str)
False
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/7C7B3CUU6LUP2FJJBKZSTSE6XK27GTKW/
Code of Conduct: http://python.org/psf/codeofconduct/