Terry J. Reedy <tjre...@udel.edu> added the comment: "can't reproduce" does not inform as to what *did* happen with which code.
More experiments: foo = str() TypeError: can only concatenate list (not "str") to list class s(str): pass foo = s() TypeError: Can't convert 'list' object to str implicitly Why is it trying to do that? Of course, the interpreter can (implicitly) convert list to tuple, which must be what happens in OP example. The subclasses of tuple and str do not gain an __radd__ method. If we add one class s(str): def __radd__(s,o): print('in radd, type(o)') foo = s() a = [1] + foo # prints "in radd <class 'list'>" no implicit conversion is done. Reversing tuple and list class Crasher(list): pass a = () + Crasher() # or Crasher([1]) print(a, type(a), len(a)) #[] <class 'list'> 0 # or [1] <class 'list'> 1 whereas a = (1,) + Crasher() crashes, so not completely symmetrical ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8847> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com