spacepy.toolbox.indsFromXrange¶
-
spacepy.toolbox.
indsFromXrange
(inxrange)[source]¶ return the start and end indices implied by an xrange, useful when xrange is zero-length
- Parameters
- inxrangexrange
input xrange object to parse
- Returns
- list of int
List of start, stop indices in the xrange. The return value is not defined if a stride is specified or if stop is before start (but will work when stop equals start).
Examples
>>> import spacepy.toolbox as tb >>> foo = xrange(23, 39) >>> foo[0] 23 >>> tb.indsFromXrange(foo) [23, 39] >>> foo1 = xrange(23, 23) >>> tb.indsFromXrange(foo) #indexing won't work in this case [23, 23]