[Python-Dev] RE: Adding item in front of a list

Raymond Hettinger python at rcn.com
Fri Apr 11 17:36:21 EDT 2003


> [Andrew Koenig, starting with l=[2, 3, 4]]
> > ...
> > I would have thought that after l.insert(-1, 1), l would be
> > [2, 3, 1, 4], but it doesn't work that way.
> 
> Alas, list.insert() existed before sequence indices were generalized to give
> a "count from the right end" meaning to negative index values.  When the
> generalization happened, it appears that list.insert() was just overlooked.
> 
> I'd like to change this.  If I did, how loudly would people scream?

+1 from me.


Raymond Hettinger





More information about the Python-list mailing list