[Python-Dev] Iterable String Redux (aka String ABC) (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Tue May 27 22🔞07 CEST 2008
- Previous message: [Python-Dev] Iterable String Redux (aka StringABC)
- Next message: [Python-Dev] Iterable String Redux (aka String ABC)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
(just my 2 eurocents)
Guido van Rossum <guido python.org> writes:
I'm not against this, but so far I've not been able to come up with a good set of methods to endow the String ABC with.
If we stay minimalistic we could consider that the three basic operations that define a string are:
- testing for substring containment
- splitting on a substring into a list of substrings
- slicing in order to extract a substring
Which gives us ['contains', 'split', 'getitem'], and expands intuitively to ['contains', 'find', 'index', 'split', 'rsplit', 'getitem'].
Another problem is that not everybody draws the line in the same place -- how should instances of bytes, bytearray, array.array, memoryview (buffer in 2.6) be treated?
In the followup of the flatten() example, bytes and bytearray should be Strings, but array.array and memoryview shouldn't. array.array is really a different kind of container rather than a proper string, and as for memoryview... well, since it's not documented I don't know what it's supposed to do :-)
Regards
Antoine.
- Previous message: [Python-Dev] Iterable String Redux (aka StringABC)
- Next message: [Python-Dev] Iterable String Redux (aka String ABC)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]