Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:24:07+00:00 2026-06-01T02:24:07+00:00

Python not support adding a tuple to a list: >>> [1,2,3] + (4,5,6) Traceback

  • 0

Python not support adding a tuple to a list:

>>> [1,2,3] + (4,5,6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list

What are the disadvantages for providing such a support in the language? Note that I would expect this to be symmetric: [1, 2] + (3, 4) and (1, 2) + [3, 4] would both evaluate to a brand-new list [1, 2, 3, 4]. My rationale is that once someone applied operator + to a mix of tuples and lists, they are likely to do it again (very possibly in the same expression), so we might as well provide the list to avoid extra conversions.

Here’s my motivation for this question.

It happens quite often that I have small collections that I prefer to store as tuples to avoid accidental modification and to help performance. I then need to combine such tuples with lists, and having to convert each of them to list makes for very ugly code.

Note that += or extend may work in simple cases. But in general, when I have an expression

columns = default_columns + columns_from_user + calculated_columns

I don’t know which of these are tuples and which are lists. So I either have to convert everything to lists:

columns = list(default_columns) + list(columns_from_user) + list(calculated_columns)

Or use itertools:

columns = list(itertools.chain(default_columns, columns_from_user, calculated_columns))

Both of these solutions are uglier than a simple sum; and the chain may also be slower (since it must iterate through the inputs an element at a time).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:24:08+00:00Added an answer on June 1, 2026 at 2:24 am

    This is not supported because the + operator is supposed to be symmetric. What return type would you expect? The Python Zen includes the rule

    In the face of ambiguity, refuse the temptation to guess.

    The following works, though:

    a = [1, 2, 3]
    a += (4, 5, 6)
    

    There is no ambiguity what type to use here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone confirm that Python 2.6 ftplib does NOT support Unicode file names? Or
I read that Python does not actually support 2D arrays but rather an array
Python does not print traceback messages from exceptions raised in daemon threads. For example,
Apparently, there's been a big brouhaha over whether or not Python needs tail-call optimization
Why does Python not support a record type natively? It's a matter of having
As python does not have concept of constants, would it be possible to raise
r'\' in Python does not work as expected. Instead of returning a string with
standard power operation ( ** ) in Python does not work for negative power!
I'm relatively new to wxPython (but not Python itself), so forgive me if I've
I know that the builtin set type in python is not generally threadsafe, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.