Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Guido van Rossum
On Mon, Sep 15, 2014 at 3:46 PM, Mark Lawrence wrote: > > I assume it's based on the concepts of slicing. From the docs > "s.insert(i, x) - inserts x into s at the index given by i (same as s[i:i] > = [x])". Ah, right. It matches thigs like s[100:] which is the empty string if s is shorter tha

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Guido van Rossum
This functionality has existed since the earliest days of Python, and even if we all agreed it was wrong we couldn't change it -- it would just break too much existing code. I can't quite remember why I did it that way but it was definitely a conscious choice; probably some symmetry or edge case. (

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Ethan Furman
On 09/15/2014 03:46 PM, Mark Lawrence wrote: On 15/09/2014 23:29, Mark Shannon wrote: I think this is an OK forum for this question. It isn't. ;) If someone isn't sure if something is a bug or not, then why not ask here before reporting it on the bug tracker? The first stop should still

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Antoine Pitrou
On Mon, 15 Sep 2014 23:46:03 +0100 Mark Lawrence wrote: > > I assume it's based on the concepts of slicing. From the docs > "s.insert(i, x) - inserts x into s at the index given by i (same as > s[i:i] = [x])". Although shouldn't that read s[i:i+1] = [x] ? No, the latter would replace the con

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Mark Lawrence
On 15/09/2014 23:29, Mark Shannon wrote: On 15/09/14 12:31, Tal Einat wrote: On Mon, Sep 15, 2014 at 6:18 AM, Harish Tech wrote: I had a list a = [1, 2, 3] when I did a.insert(100, 100) [1, 2, 3, 100] as list was originally of size 4 and I was trying to insert value at index 100 , it

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Mark Shannon
On 15/09/14 12:31, Tal Einat wrote: On Mon, Sep 15, 2014 at 6:18 AM, Harish Tech wrote: I had a list a = [1, 2, 3] when I did a.insert(100, 100) [1, 2, 3, 100] as list was originally of size 4 and I was trying to insert value at index 100 , it behaved like append instead of throwing an

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Harish Tech
Hi , Sorry for that mistake . Now I have posted it in python-list mailing list . Thanks for your guidance. Harish On Mon, Sep 15, 2014 at 5:01 PM, Tal Einat wrote: > On Mon, Sep 15, 2014 at 6:18 AM, Harish Tech > wrote: > > I had a list > > > > a = [1, 2, 3] > > > > when I did > > > >

Re: [Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-15 Thread Tal Einat
On Mon, Sep 15, 2014 at 6:18 AM, Harish Tech wrote: > I had a list > > a = [1, 2, 3] > > when I did > > a.insert(100, 100) > > [1, 2, 3, 100] > > as list was originally of size 4 and I was trying to insert value at index > 100 , it behaved like append instead of throwing any errors as I was tryin

[Python-Dev] List insert at index that is well out of range - behaves like append

2014-09-14 Thread Harish Tech
I had a list a = [1, 2, 3] when I did a.insert(100, 100) [1, 2, 3, 100] as list was originally of size 4 and I was trying to insert value at index 100 , it behaved like append instead of throwing any errors as I was trying to insert in an index that did not even existed . Should it not thro