A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-September/136340.html below:

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

[Python-Dev] List insert at index that is well out of range - behaves like append [Python-Dev] List insert at index that is well out of range - behaves like appendAntoine Pitrou solipsis at pitrou.net
Tue Sep 16 00:54:03 CEST 2014
On Mon, 15 Sep 2014 23:46:03 +0100
Mark Lawrence <breamoreboy at yahoo.co.uk> 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 contents at index i, while the former
inserts it (formally, it replaces the 0-length slice with a 1-length
slice).

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4