[Python-ideas] Allow "assigning" to Ellipse to discard values.

Daniel Holth dholth at gmail.com
Wed Feb 11 16:20:26 CET 2015


How about zero characters between commas? In ES6 destructing
assignment you'd writes something like ,,c = (1,2,3)

On Wed, Feb 11, 2015 at 9:38 AM, Jonas Wielicki
<j.wielicki at sotecware.net> wrote:
> On 10.02.2015 22:01, Spencer Brown wrote:
>> Basically, in any location where a variable name is provided for assignment (tuple unpacking, for loops, function parameters, etc) a variable name can be replaced by '...' to indicate that that value will not be used. This would be syntactically equivalent to del-ing the variable immediately after, except that the assignment never needs to be done.
>>
>> Examples:
>>>>> tup =  ('val1', 'val2', (123, 456, 789))
>>>>> name, ..., (..., value, ...) = tup
>> instead of:
>>>>> name = tup[0]
>>>>> value = tup[2][1]
>> This shows slightly more clearly what format the tuple will be in, and provides some additional error-checking - the unpack will fail if the tuple is a different size or format.
>
> I don’t like that syntax at all. With _ it is much more readable. In
> that context, ... rather looks like what *_ would do: Leaving out many
> elements (even though that is not possible in python currently, at least
> not in (*_, foo, *_); that only makes things worse).
>
> This may be arbitrarily confusing. As others have said, just use
>
>>>> tup =  ('val1', 'val2', (123, 456, 789))
>>>> name, _, (_, value, _) = tup
>
>
>
> regards,
> jwi
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list