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 930737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:23:11+00:00 2026-05-15T20:23:11+00:00

This question is going to be rather long, so I apologize preemptively. In Python

  • 0

This question is going to be rather long, so I apologize preemptively.

In Python we can use * in the following three cases:

I. When defining a function that we want to be callable with an arbitrary number of arguments, such as in this example:

def write_multiple_items(file, separator, *args):
    file.write(separator.join(args))

In this case, the excess positional arguments are collected into a tuple.

II. The reverse case is when the arguments are already in either a list or a tuple and we wish to unpack them for a function call requiring separate positional arguments, such as in this example:

>>> range(3, 6)             # normal call with separate arguments
[3, 4, 5]
>>> args = [3, 6]
>>> range(*args)            # call with arguments unpacked from a list
[3, 4, 5]

III. Starting with Python 3, * is also used in the context of extended list or tuple unpacking, such as in this example for tuples:

>>> a, *b, c = range(5)
>>> b
[1, 2, 3]

or for lists:

>>> [a, *b, c] = range(5)
>>> b
[1, 2, 3]

In both cases, all items from the iterable being unpacked that are not assigned to any of the mandatory expressions are assigned to a list.

So here’s the question: in case I the extra args are collected into a tuple, while in case III the extra items are assigned to a list. Whence this discrepancy? The only explanation I could find was in PEP 3132 which says that:

Possible changes discussed were:

[…]

Make the starred target a tuple instead of a list. This would be
consistent with a function’s *args,
but make further processing of the
result harder.

However, from a pedagogical perspective this lack of consistency is problematic, especially given that if you wanted to process the result, you could always say list(b) (assuming b in the above examples was a tuple). Am I missing something?

  • 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-05-15T20:23:12+00:00Added an answer on May 15, 2026 at 8:23 pm

    In Python we can use * in the
    following three cases:

    You mean prefix * , of course — infix * is used for multiplication.

    However, from a pedagogical
    perspective this lack of consistency
    is problematic, especially given that
    if you wanted to process the result,
    you could always say list(b) (assuming
    b in the above examples was a tuple).
    Am I missing something?

    I would say that the design problem (old and very long in the tooth!) is with the fact that when you’re receiving arbitrary arguments you’re getting them as a tuple, when a list would be more useful in many cases with no real downside (the tiny amount of extra processing and memory that may be needed to make a list instead of a tuple is negligible in the context of function call overhead — or sequence unpacking, for that matter; the extra processing and memory needed to make a list as well as a tuple is really more annoying).

    There’s very little that you can do with a tuple but not a list — basically, just hashing it (to use as a set item or dict key) — while a list offers much more extra functionality, and not just for purposes of altering it… methods such as count and index are also useful.

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

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The easiest (and best) method is to call Activator.CreateInstance yourself.… May 16, 2026 at 4:29 pm
  • Editorial Team
    Editorial Team added an answer $('#someDiv') is selecting the element with ID="someDiv", so selectors might… May 16, 2026 at 4:29 pm
  • Editorial Team
    Editorial Team added an answer About why gdb cannot access the memory you want, I… May 16, 2026 at 4:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Long-delayed update I'm accepting MUG4N's answer to this question, and I also want to
I have a rather long switch-case statement. Some of the cases are really short
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
I have a theory question rather than an error report. I'm a rookie C++
I am returning to C++ after a long absence and I am stumbling a
I'm really drawing a blank on this one. I've been working on globalization but
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
Going through some of my older Delphi projects and upgrading them to D2009, as
Though the question is very specific, I'd also really appreciate general advice and other
I'm going through the full tutorial at cplusplus.com, coding and compiling each example manually.

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.