[Python-ideas] iterable.__unpack__ method

Steven D'Aprano steve at pearwood.info
Tue Feb 26 05:03:22 CET 2013


On 26/02/13 11:19, MRAB wrote:
> On 2013-02-26 00:07, Steven D'Aprano wrote:
>> On 26/02/13 10:30, Greg Ewing wrote:
>>> Devin Jeanpierre wrote:
>>>> On Mon, Feb 25, 2013 at 7:45 AM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
>>>>>    a, b, *() = iterable
>>>>
>>>> Of course, you can't unpack anything into (), because Python never had
>>>> that syntax, but you get the idea.
>>>
>>> -1, this is just as arbitrary as ... or a lone *.
>>>
>>> I prefer ... myself, because visually it has a low profile
>>> and doesn't draw undue attention to something that you're
>>> saying you don't care about.
>>>
>>> Maybe ... could be blessed as an official "don't care"
>>> assignment target, like _ in Haskell. That would make this
>>> usage less of a special case (although it would still be
>>> partially special, since it suppresses unpacking of the
>>> rest of the iterator).
>>
>> Please no. _ is already overloaded too much. In i18n contexts, _ is
>> conventionally used as the function for getting display text. In the
>> interactive interpreter, _ is used for the last result. And in source
>> code, _ is often used by convention as a "don't care" variable.
>>
> [snip]
> He didn't say that we should use "_", he said that "..." would be like
> "_" in Haskell.


/facepalm

And so he did. Sorry about that Greg!

But still, I think this does help demonstrate that symbols are not
always the easiest to read at a glance. It's too easy for the eyes to
slide right off them, unless they are as familiar as basic arithmetic.


-- 
Steven



More information about the Python-ideas mailing list