Terry J. Reedy <tjre...@udel.edu> added the comment:

I think Nick's point, and one I agree with, is (or amounts to):
  'somelist += ob' == 'somelist.__iadd__(ob)' ==
  'somelist.extend(ob)' == 'somelist[len(somelist):len(somelist)]=ob'
is defined and should be implemented for all somelist,ob pairs. If ob is an 
iterable, add the items at the end; if not, raise TypeError.

CPython currently has a bug that breaks the middle equality in a peculiar case. 
We recognize that and hope to fix it.

The proper, future-proof fix for Greg Price & Co. is for them to 
  1. use somelist.append(ob) to append a single object, iterable or not, to 
somelist. If they insist on (mis)using += for appending, 
  2. add the trivial __iter__ yielding just the instance to all classes whose 
instances are ever a target of 'somelist += instance'. Or
  3. wrap each non-iterable instance in an iterable, such as a tuple:
 "somelist += (non-iterable,).
Any of these (1. actually) should have been done in the first place, as has 
always been documented.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11477>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to