This is really strange to me, because by default I thought unpacking gives tuples.
In my case I want to use the prefix
keys for caching, so a tuple is preferred.
# The r.h.s is a tuple, equivalent to (True, True, 100)
*prefix, seed = ml_logger.get_parameters("Args.attn", "Args.memory_gate", "Args.seed")
assert type(prefix) is list
But I thought unpacking would return a tuple instead.
Here is the relevant PEP: https://www.python.org/dev/peps/pep-3132/
-- Update --
Given the comment and answers bellow, specifically I was expecting the unpacking to give a tuple because in function arguments a spread arg is always a tuple instead of a list.
As Jason pointed out, during unpacking one would not be able to know the length of the result ahead of time, so implementation-wise the catch-all has to start as a list for dynamic appends. Converting it to a list is a waste of effort the majority of the time.
Semantically, I would prefer to have a tuple for consistency.