[Python-3000] Making strings non-iterable

Ian Bicking ianb at colorstudy.com
Thu Apr 13 21:06:29 CEST 2006


Giovanni Bajo wrote:
>>Thus you would do:
>>
>>   for c in a_string.chars():
>>       print c
> 
> 
> Would this remove __getitem__? I believe I wouldn't want to give up s[0] as
> "the first character in s". That would make a string a thing where you can
> use [3] to access the third character, but still not iterable.

Definitely __getitem__ should stay, there's nothing wrong with that 
part.  str.__iter__ would raise NotImplemented.

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Python-3000 mailing list