Restarting this with an improved title "Bare" vs "Raw", and I will try not to
digress so much in the new thread.
My suggestion is to allow a bare asterisk at the end of a desctructuring
expression to indicate that additional elements are to be ignored if present
and not iterated over if the rhs is being evaluated by iterating.
(first, second, *) = items
This provides a way of using destructuring from something that will be
processed by iterating and for which the number of items might be very large
and/or accessing of successive items is expensive.
As Paul Moore pointed out in the original thread, itertools.islice can be used
to limit the number of items iterated over. That's a nice solution, but it
required knowing or thinking of the solution, an additional import, and
repetition of the count of items to be destrucured at the outermost nesting
level on the lhs.
What are people's impressions of this idea. Is it valuable enough to pursue
writing a PEP?
If so, then what should I do in writing the PEP to make sure that it's somewhat
close to something that can potentially be accepted? Perhaps, there is a guide
for doing that?
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/4DN7T3NZEAUPJBA2SNJ4YWM564QPVE5N/
Code of Conduct: http://python.org/psf/codeofconduct/