[issue39641] concatenation of Tuples
Steven D'Aprano
report at bugs.python.org
Sun Feb 16 04:35:59 EST 2020
Steven D'Aprano <steve+python at pearwood.info> added the comment:
[Bruce]
> but try this, and it will NOT work:
>
> FatThing= [(5, 4, "First Place"),
> (6, 6, "Fifer Place"),
> (2, 2, "Slowr Place")]
> print(FatThing) #this works
>
> FFThing = FatThing + ('22', '32', '55') #this causes an error!
That is correct, it should cause an error because you are trying to
concatenate a list and a tuple. This is an easier way to show the same
behaviour:
[] + () # fails with TypeError
[Bruce]
> however if you change all the members to strings, it will work!!!
I'm afraid you are mistaken. It still fails, as it should.
py> FatThing = [("a", "b", "First Place"),
... ("c", "d", "Fifer Place"),
... ("e", "f", "Slowr Place")]
py> FFThing = FatThing + ('22', '32', '55')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
Please take more care when trying to report what you think is a bug.
Remember that Python is about 30 years old and there are tens or
hundreds of thousands of people using it every single day. 99% of the
time, anything you, or I, find that looks like a bug, is a bug in *our*
code, not Python. Especially when it is something as basic and
fundamental as tuple concatenation.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39641>
_______________________________________
More information about the Python-bugs-list
mailing list