Adding item in front of a list
Skip Montanaro
skip at pobox.com
Wed Apr 9 11:36:11 EDT 2003
>> I would have thought that after l.insert(-1, 1), l would be
>> [2, 3, 1, 4], but it doesn't work that way.
Tim> Alas, list.insert() existed before sequence indices were
Tim> generalized to give a "count from the right end" meaning to
Tim> negative index values. When the generalization happened, it
Tim> appears that list.insert() was just overlooked.
Tim> I'd like to change this. If I did, how loudly would people scream?
No screams from here. I don't think I've ever used list.insert() with an
index of anything but 0.
Skip
More information about the Python-list
mailing list