[Python-ideas] values in vs. values out

Masklinn masklinn at masklinn.net
Thu Jan 13 23:59:55 CET 2011

On 2011-01-13, at 22:31 , Jason Orendorff wrote:

> On Thu, Jan 13, 2011 at 3:10 PM, Masklinn <masklinn at masklinn.net> wrote:
>> On 2011-01-13, at 21:11 , Jason Orendorff wrote:
>>> (c) Unlike ML, you can write
>>>       (a, b) = [1, 2]
>>>     or generally
>>>       a, b = any_iterable
>>>     It is useful for unpacking to depend on the iterable protocol
>>>     rather than the exact type of the right-hand side. This is a
>>>     nicety that ML-like languages don't bother with, afaik.
>> In no small part because, in ML-type languages (or more generally in
>> functional languages, Erlang could hardly be called an ML-like language)
>> lists (or more generally sequences) and tuples are very different beasts and
>> entirely incompatible.
> Well, sure, as far as tuples go. But the point I was making was more
> general. Python has a notion of "iterable" which covers many types,
> not just "list". The iterable protocol is used by Python's for-loops,
> sorted(), str.join() and so on; it's only natural for unpacking
> assignment to use it as well. As far as I know, most ML languages
> don't have that notion.* So Python has a reason for this asymmetry
> that those languages don't have.
Well yeah, but even if those languages had a higher-level "iterable" abstraction, tuples wouldn't be part of it.

More information about the Python-ideas mailing list