[Python-Dev] Extending tuple unpacking

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 12 04:16:16 CEST 2005

Nick Coghlan wrote:

> I'm also trying to figure out why you would ever write:
>    [a, b, c, d] = seq

I think the ability to use square brackets is a
holdover from some ancient Python version where you had
to match the type of the thing being unpacked with
the appropriate syntax on the lhs. It was a silly
requirement from the beginning, and it became
unworkable as soon as things other than lists and
tuples could be unpacked.

In Py3k I expect that [...] for unpacking will
no longer be allowed.

> Indeed. It's a (minor) pain that optional flag variables and variable length 
> argument lists are currently mutually exclusive. Although, if you had that 
> rule, I'd want to be able to write:
>    def f(a, b, *, foo=1, bar=2): pass

Yes, I agree.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list