Timeline for answer to How slicing in Python works by David M. Perlman
Current License: CC BY-SA 4.0
Post Revisions
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 9, 2024 at 12:45 | comment | added | nutty about natty | Should be read in conjunction with this great answer to stackoverflow.com/questions/31593201/…. | |
| Apr 6, 2023 at 11:08 | comment | added | Simo | p[2:3] = 't' works fine ! there should be no TypeError ! | |
| Sep 1, 2022 at 17:21 | comment | added | Edamame |
Curious about what's the time complexity of doing r[1:1]=['blah'] ? thanks!
|
|
| Jul 25, 2022 at 19:46 | comment | added | David M. Perlman | The first way works for a list or a string; the second way only works for a list, because slice assignment isn't allowed for strings. Other than that I think the only difference is speed: it looks like it's a little faster the first way. Try it yourself with timeit.timeit() or preferably timeit.repeat(). They are super easy to use and very educational, it's worth getting used to playing with them all the time! | |
| Jul 24, 2022 at 18:00 | comment | added | Alex O |
If I wanted to remove the 1st x elements of a list, what will be better: l = l[6:] or l[:] = l[6:]?
|
|
| Jan 2, 2019 at 16:44 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Active reading [<http://en.wikipedia.org/wiki/ASCII> <http://en.wikipedia.org/wiki/Python_%28programming_language%29>].
|
| Nov 30, 2018 at 17:43 | history | edited | David M. Perlman | CC BY-SA 4.0 |
Accidental edit to "original answer" introduced errors; reverted to original version
|
| Nov 30, 2018 at 17:36 | history | edited | David M. Perlman | CC BY-SA 4.0 |
edited body
|
| Nov 23, 2018 at 0:11 | history | edited | David M. Perlman | CC BY-SA 4.0 |
added 6 characters in body
|
| Sep 26, 2018 at 4:46 | history | edited | David M. Perlman | CC BY-SA 4.0 |
Added dramatically increased detail of slice assignment
|
| Feb 3, 2015 at 13:54 | review | Suggested edits | |||
| Feb 3, 2015 at 14:29 | |||||
| Apr 4, 2013 at 23:33 | review | Suggested edits | |||
| Apr 4, 2013 at 23:46 | |||||
| S Sep 4, 2011 at 4:27 | history | suggested | TomRoche | CC BY-SA 3.0 |
improved grammar, linked (conceptually) to Nowak discussion
|
| Sep 4, 2011 at 2:27 | review | Suggested edits | |||
| S Sep 4, 2011 at 4:27 | |||||
| Jan 18, 2011 at 21:37 | history | answered | David M. Perlman | CC BY-SA 2.5 |