On Sun, Oct 13, 2019 at 12:52 PM Andrew Barnert via Python-ideas < python-ideas@python.org> wrote:
> The main problem is that a str is a sequence of single-character str, each > of which is a one-element sequence of itself, etc. forever. If you wanted > to change this, I think it would make more sense to go the opposite way: > leave str a sequence, but make it a sequence of char objects. (And > likewise, bytes and bytearray could be sequences of byte objects—or just go > all the way to making them sequences of ints.) And then maybe add a c > prefix for defining char constants, and you’ve solved all the problems > without having to add new confusing methods or properties. > I've thought for a long time that this would be a "good thing". the "string or sequence of strings" issues is pretty much the only hidden-bug-triggering type error I've gotten since "true division". The only way we really live with it fairly easily is that strings are pretty much never duck typed -- so I can check if I got a string, and then I know I didn't get a sequence of strings. But I've always wondered how disruptive it would be to add a char type -- it doesn't seem like it would be very disruptive, but I have not thought it through at all. And I'm not sure how much string functionality a char should have -- probably next to none, as the point is that it would be easy to distinguish from a string that happened to have one character. By the way, the bytes and bytearray types already does this -- index into or loop through a bytes object, you get an int. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QV2SLFQAR2VKOLD5Y7ACRO6LBX4ZE5UQ/ Code of Conduct: http://python.org/psf/codeofconduct/