I am curious on why python3's star unpacking returns me an instance of a list as compared to a tuple (which is returned by an asterisk in function argument). Is this a python's idiosyncrasy, or there is a good reason behind this.
In [1]: def foo(*args):
...: print(type(args))
...:
In [2]: foo(1, 2, 3, 4)
<class 'tuple'>
In [3]: first, *rest = (1, 2, 3, 4)
In [4]: type(rest)
Out[4]: list
They figured a list would be easier to process:
After a short discussion on the python-3000 list [1], the PEP was accepted by Guido in its current form. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With