You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2017-04-22.18:16:43.046>created_at=<Date2017-04-22.14:01:58.944>labels= ['type-bug', 'invalid']
title='Equivalent syntax regarding List returns List objects with non-similar list elements.'updated_at=<Date2017-04-22.18:16:43.044>user='https://bugs.python.org/AkshayDeogaonkar'
The behaviour is as documented and is not a bug. When you have a three-argument extended slice, the starting and stopping values depend on whether the stride (step) is positive or negative. Although that's buried in a footnote to the table.
The current behaviour is necessary so that the common case of both start and stop being blank is supported correctly for negative stride:
py> "abcde"[::-1]
'edcba'
So with a positive stride, your first example lst[0:3:-1] starts at index 0, ends at index 3, with step -1. That is an empty slice.
But your second example lst[:3:-1] starts at the end of the list, index len(lst), ends at 3, with step -1. That is equivalent to lst[5:3:-1] which is not the same as your first example.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: