About 51 results
Open links in new tab
  1. slice - How slicing in Python works - Stack Overflow

    The colon, :, is what tells Python you're giving it a slice and not a regular index. That's why the idiomatic way of making a shallow copy of lists in Python 2 is

  2. What does the slice() function do in Python? - Stack Overflow

    Jul 19, 2015 · Whenever some other code uses slice notation on your an instance of your class Python will call your __getitem__ method with a slice object. (Older versions of Python used a __getslice__ …

  3. How can I use Python built-in slice object? - Stack Overflow

    Oct 12, 2010 · The index or slice is passed to the methods as a single argument, and the way Python does this is by converting the slice notation, (1:10:2, in this case) to a slice object: slice(1,10,2).

  4. What is :: (double colon) in Python when subscripting sequences?

    Aug 10, 2010 · 22 When slicing in Python the third parameter is the step. As others mentioned, see Extended Slices for a nice overview. With this knowledge, [::3] just means that you have not …

  5. what does [::-1] mean in python - slicing? - Stack Overflow

    Python interpreter is smart enough to convert a slice of range into another range. This is an optimization, ranges are generators. They are dynamic, i.e. they don't hold all the elements in the memory at once. …

  6. How to slice a list from an element n to the end in Python?

    To my understanding, slice means lst[start:end], and including start, excluding end. So how would I go about finding the "rest" of a list starting from an element n?

  7. How to slice a list in Python - Stack Overflow

    How to slice a list in Python Ask Question Asked 16 years, 4 months ago Modified 4 years, 1 month ago

  8. python - How to slice column values in pandas DataFrame - Stack …

    How to slice column values in pandas DataFrame Asked 8 years ago Modified 7 months ago Viewed 27k times

  9. Performance of list.extend slice vs islice - Stack Overflow

    May 2, 2025 · extend_slice and extend_islice are your tests, we see time differences similar to what you saw. just_slice just creates the string slices but does nothing with them. Wee see they're very cheap …

  10. Why are Python's slice and range upper-bound exclusive?

    Here’s a useful invariant of slice operations: s[:i] + s[i:] equals s. For non-negative indices, the length of a slice is the difference of the indices, if both are within bounds. For example, the length of word[1:3] …