[Python-Dev] syntactic shortcut - unpack to variably sized list
James Y Knight
foom at fuhm.net
Sat Nov 13 08:02:23 CET 2004
On Nov 11, 2004, at 4:50 PM, Johan Hahn wrote:
> As far as I can tell from the archive, this has not been discussed
> before.
> [...]
> I think it would be nice if the following was legal:
> >>> a,b,*L = 'a b 1 2 3'.split(' ')
> >>> a, b, L
> ('a', 'b', ['1', '2', '3'])
Oh, this has been discussed before. It's come up quite a number of
times, in fact. But, it's been rejected every time. FWIW [which is very
little ;)], I agree: this would be nice. I'm strongly for consistency
and orthogonality: there should be few distinct concepts in the
language each of which works in many places. Allowing * only in an
function call but not in other tuple-constructing situations violates
this concept, IMO. It would have been great if this had been added at
the same time as * in function calls. Adding it now may be more trouble
than it's worth, though.
Two threads on the topic, with rejections by Guido:
http://mail.python.org/pipermail/python-dev/2002-November/030349.html
http://mail.python.org/pipermail/python-dev/2004-August/046684.html
Guido's rejection from
http://mail.python.org/pipermail/python-dev/2004-August/046794.html:
> For the record, let me just say that I'm -1 on adding this feature
> now. It's only a minor convenience while it's a fairly big change to
> the parser and code generator, but most of all, Python's growth needs
> to be reduced. If we were to add every "nice" feature that was
> invented (or present in other languages), Python would lose one of its
> main charms, which is that it is really a rather simple language that
> can be learned and put to production quickly.
>
> So while I appreciate the idea (which BTW has been proposed before) I
> think it's not worth adding now, and if you don't hear from me again
> on this topic it's because I haven't changed my mind...
James
More information about the Python-Dev
mailing list