* Georg Dahn [EMAIL PROTECTED] [060423 01:39]:
Hi!
Well, you are right that this is at least from a mathematical point of
view correct. I have given this a second thought and you seem to be
right, that, if a[M:N] for M or N len(a) returns an empty list, many
problems can be solved more
Hi!
a[M:N] should _never_ produce errors because returning an empty (or
truncated) list for a[M:N] unambiguously conveys to the programmer
that M len(a) (or N len(a)).
In my opinion one has done something wrong if one wants to get a sublist
whith wrong bounds. That's why an error has
something wrong.
The most common use-case for the slice operation I can think of is:
for item in somelist[M:N]
do something
endfor
This is a good example. M and N are not further described here. But M
and N must come from somewhere. If they are out of bounds, then in many
or even
Hi,
I think that the main point of disagreement between Georg (and possibly
others) and me is summed up by the expectation of what a[M:N] behaves
like.
I imagine the most common use of a[M:N] to be like get(dict, key) where
the programmer is already well aware that the key might not exist
Hi!
I think trying to get items from an empty list should produce an error
message.
IMHO it would be a serious error if no error were produced in this case.
Best wishes,
Georg
___
24 FIFA World Cup tickets to be
On Fri, 21 Apr 2006 22:51:11 +0200
Bram Moolenaar [EMAIL PROTECTED] wrote:
a[M:N] does truncate when N len(a). However, this still gives an
error when len(a) = 0. Can this be changed as well to return just an
empty list? I appreciate your changing the previous behavior. It made
things
Hi!
Handling N len(a) except when a happens to be 0 seems a bit
counterintuitive.
No: Let's assume, that you have an empty list a. Then M in a[M:N] is
always out of bounds, which should produce an error. Analogously, if a
is not empty, but M len(a), an error should be produced, too. (BTW
On Fri, 21 Apr 2006 23:33:07 +0200
Georg Dahn [EMAIL PROTECTED] wrote:
Hi Georg,
No: Let's assume, that you have an empty list a. Then M in a[M:N] is
always out of bounds, which should produce an error. Analogously, if a
is not empty, but M len(a), an error should be produced, too. (BTW