[Python-ideas] discontinue iterable strings
Michael Selik
michael.selik at gmail.com
Sun Aug 21 02:34:56 EDT 2016
On Sun, Aug 21, 2016 at 1:27 AM Chris Angelico <rosuav at gmail.com> wrote:
> Hmm. It would somehow need to be recognized as "not iterable". I'm not
> sure how this detection is done; is it based on the presence/absence
> of __iter__, or is it by calling that method and seeing what comes
> back? If the latter, then sure, an __iter__ that raises would cover
> that.
>
The detection of not hashable via __hash__ set to None was necessary, but
not desirable. Better to have never defined the method/attribute in the
first place. Since __iter__ isn't present on ``object``, we're free to use
the better technique of not defining __iter__ rather than defining it as
None, NotImplemented, etc. This is superior, because we don't want __iter__
to show up in a dir(), help(), or other tools.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160821/c4537a38/attachment.html>
More information about the Python-ideas
mailing list