Remarks to Python 2.3
Michael Hudson
mwh at python.net
Wed Sep 25 07:41:29 EDT 2002
Markus Schaber <use-net at schabi.de> writes:
> - When replacing list elements using the extended slice syntax - e. G.
> in a[::2] = range(0, -2, -1) - the left side must have exactly the same
> numer of elements as the right side. So, to cite the example, a[::2] =
> range(3) is illegal for a=[0, 1, -1, 3].
>
> Now I could image that it makes sense to allow one single additional
> element to be added to the list in case only the step is specified and
> the operation doesn't produce a gap. So the given example above would be
> valid, giving a sequence of five elements, whereas with a=[0, 1, 2] it
> would stay illegal (as it would produce a gap). a[0:3:2]=range(3) would
> stay illegal as it explicitly specifies the length of the range,
> a[0:3:5]=range(3) could be allowed.
Wanna implement that? I agree it sounds reasonable. This sort of
thing is way harder to get right than you might think, though.
If you (or anyone else) submits a patch, I'll review it.
Cheers,
M.
--
Monte Carlo sampling is no way to understand code.
-- Gordon McMillan, comp.lang.python
More information about the Python-list
mailing list