This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients benrg, jackdied, r.david.murray, terry.reedy
Date 2010-06-05.00:39:32
SpamBayes Score 0.005199408
Marked as misclassified No
Message-id <1275698375.37.0.270594662155.issue8847@psf.upfronthosting.co.za>
In-reply-to
Content
"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
History
Date User Action Args
2010-06-05 00:39:35terry.reedysetrecipients: + terry.reedy, jackdied, r.david.murray, benrg
2010-06-05 00:39:35terry.reedysetmessageid: <1275698375.37.0.270594662155.issue8847@psf.upfronthosting.co.za>
2010-06-05 00:39:33terry.reedylinkissue8847 messages
2010-06-05 00:39:32terry.reedycreate