On Wed, Oct 23, 2019, at 19:00, Christopher Barker wrote:
> 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.

There's lots of functionality that's on str that if I were designing the 
language I'd put on character.

character type functions are definitely in - and, frankly, str.isnumeric is an 
attractive nuisance, it may well make sense to remove it from str and require 
explicit use of all().
upper/lower is tricky - cases like ß can change the length of a string... maybe 
put it on char but return a string?
No reason not to allow + or * to concatenate chars to each other or to strings, 
multiply a char to a string
_______________________________________________
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/OD5B2OOVMZ46RURZCMYFHQ7GSUPXVS5F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to