[Python-ideas] Boundaries for unpacking
Stephen J. Turnbull
stephen at xemacs.org
Sun Apr 10 12:33:53 EDT 2016
Michel Desmoulin writes:
> Yes and you can also do that for regular slicing on list. But you don't,
> because you have regular slicing, which is cleaner, and easier to read
> and remember.
It's clean because it's well-defined. Slices on general iterables
don't have an OWTDI. For example, "a = somelist[:]" is an idiom for
copying somelist to a so that destructive manipulations of a don't
change the original. Should "a = someiterable[:]" reproduce those
semantics? After "head, tail = someiterable" should tail contain a
list or someiterable itself or something else?
"WIBNI iterable[] worked" has already been posted to this thread about
5 times, and nobody disagrees that IWBN. But slicing and unpacking of
iterables are fraught with such issues. It's time the wishful
thinkers got down to edge cases and wrote a PEP.
More information about the Python-ideas
mailing list