Message130925
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. |
|
Date |
User |
Action |
Args |
2011-03-14 23:03:44 | terry.reedy | set | recipients:
+ terry.reedy, arigo, ncoghlan, Carl.Friedrich.Bolz, eric.araujo, Trundle, meador.inge, daniel.urban |
2011-03-14 23:03:44 | terry.reedy | set | messageid: <1300143824.86.0.786235090512.issue11477@psf.upfronthosting.co.za> |
2011-03-14 23:03:43 | terry.reedy | link | issue11477 messages |
2011-03-14 23:03:43 | terry.reedy | create | |
|