[Python-3000] Making strings non-iterable

Barry Warsaw barry at python.org
Thu Apr 13 21:09:21 CEST 2006


On Thu, 2006-04-13 at 13:01 -0500, Ian Bicking wrote:
> I propose that strings (unicode/text) shouldn't be iterable.

+1.  I think I've mentioned before that we have a particular choke point
that may get scalars or sequences, but that everything coming out of
that choke point is guaranteed to be a sequence.  You can use iter() on
the thing, but you have to typecheck that it's not a basestring first.

> Should bytes be iterable as well?  Because bytes (the container) and 
> integers are not interchangeable, the problems that occur with strings 
> seem much less likely, and the container-like nature of bytes is 
> clearer.  So I don't propose this effect bytes in any way.

That seems right.  bytes probably won't suffer from the Python String
Photonic Effect (that they're both waves and particles, er, I mean
sequences and scalars).

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-3000/attachments/20060413/9b1b487b/attachment.pgp 


More information about the Python-3000 mailing list