Message362063
[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. |
|
Date |
User |
Action |
Args |
2020-02-16 09:35:59 | steven.daprano | set | recipients:
+ steven.daprano, SilentGhost, ammar2, bruceblosser |
2020-02-16 09:35:59 | steven.daprano | link | issue39641 messages |
2020-02-16 09:35:58 | steven.daprano | create | |
|