File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
source_py3/python_toolbox/sequence_tools Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -176,12 +176,20 @@ def __getitem__(self, i):
176176 return self .start + (self .step * (i + self .length ))
177177 else :
178178 raise IndexError
179+ elif i == infinity :
180+ if self .length == infinity :
181+ return self .stop
182+ else :
183+ raise IndexError
184+ elif i == - infinity :
185+ raise IndexError
179186 elif isinstance (i , (slice , sequence_tools .CanonicalSlice )):
180187 canonical_slice = sequence_tools .CanonicalSlice (
181188 i , iterable_or_length = self
182189 )
183- if not (0 <= canonical_slice .start < self .length and
184- 0 <= canonical_slice .stop < self .length ):
190+ if not ((0 <= canonical_slice .start < self .length ) and
191+ ((0 <= canonical_slice .stop < self .length ) or
192+ (canonical_slice .stop == self .length == infinity ))):
185193 raise TypeError
186194 return CuteRange (
187195 self [canonical_slice .start ],
You can’t perform that action at this time.
0 commit comments