Skip to content Skip to sidebar Skip to footer

Slice Syntax To Object

I have a class holding data (a numpy ndarray) that includes a method storing the data to a mat-file (using scipy.io.savemat). The data can be very large, so I may only want to stor

Solution 1:

The answer on Passing Python slice syntax around to functions is correct, but as you're already using NumPy you can use np.s_:

import numpy as np
np.s_[1:2:3]
Out[1]: slice(1, 2, 3)

Post a Comment for "Slice Syntax To Object"