[Python-ideas] discontinue iterable strings
Alexander Heger
python at 2sn.net
Fri Aug 19 23:13:51 EDT 2016
standard python should discontinue to see strings as iterables of
characters - length-1 strings. I see this as one of the biggest design
flaws of python. It may have seem genius at the time, but it has passed it
usefulness for practical language use. For example, numpy has no issues
>>> np.array('abc')
array('abc', dtype='<U3')
whereas, as all know,
>>> list('abc')
['a', 'b', 'c']
Numpy was of course design a lot later, with more experience in practical
use (in mind).
Maybe a starting point for transition that latter operation also returns
['abc'] in the long run, could be to have an explicit split operator as
recommended use, e.g.,
'abc'.split()
'abc'.split('')
'abc'.chars()
'abc'.items()
the latter two could return an iterator whereas the former two return lists
(currently raise exceptions).
Similar for bytes, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160820/6adf4972/attachment.html>
More information about the Python-ideas
mailing list