Massimiliano Culpo <massimiliano.cu...@googlemail.com> added the comment:

Steven and Stefan, thanks for the quick replies, even though they are giving 
slightly different answers to the same questions :-)

@steven.daprano
> You refer to the docs that specify extended syntax as [start:stop:step] but 
> then you tried [start:stop,step] which is correctly an error. (Notice the 
> comma instead of colon.)

Maybe you missed the quote from the docs: "For example: a[start:stop:step] or 
a[start:stop, i]"

You say that the docs "specify extended syntax as [start:stop:step]". 
Apparently you're also surprised this syntax exists, and didn't notice that the 
error is not a SyntaxError, but a TypeError. I argue then that the syntax is 
there. If I get correctly what @skrah says, he seems to suggest that the syntax 
is there, but no built-in type is using it. Am I right?

> And again, your third issue to do with list.insert ... what is your actual 
> bug report? Have you found an example where these aren't equivalent?

I didn't say that. I actually said "`insert` really behaves like `s[i:i] = 
[x]`". But the docs from the interpreter say:
```
help(list.insert)
Help on method_descriptor:
insert(...)
    L.insert(index, object) -- insert object before index

```
What does it mean to insert an object before index 101 or -101 of a 4 items 
list? I think if the help said "-- same as L[index:index] = [object]" I would 
have been fine with it.

> Please don't report three issues under one ticket, unless they are so closely 
> related that they cannot be separated.

Apologies if this was not correct (I see you started an issue with a smaller 
scope). But I thought they were closely related, because all three might have 
been fixed by a rewording of a few parts of the docs dealing with slices.

@skrah
> I see the first issue now and I agree that Python behaves strangely.

To be clear, I don't have issues with:
```
>>> lst = [1,2,3]
>>> lst[1:2] = [1,2,3,4,5]
>>> lst
[1, 1, 2, 3, 4, 5, 3]
```
in Python, which probably is a widely used idiom to modify lists. 

My concerns are with the fact that you get the same behavior when you use 
`lst[1:2:1]` (which in my understanding is an extended slice), but you get a 
`ValueError` for any other value of `slice.step`. That might be something worth 
clarifying as part of issue32289 maybe?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32288>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to