I am reading in Python a Matlab mat file, which contains three arrays: tom, dick and harry. In Python, I use a for loop which does operations on this array list. Following is the demo-code:
import scipy.io as sio
mat_contents = sio.loadmat('names.mat') # with arrays tom, dick and harry
varlist = ['tom', 'dick', 'harry']
for w in varlist:
cl = mat_contents[w]
# some more operations in the loop
Now that I have to debug and do not want to access all the three varlist for the for loop. How to run the for loop only for harry? I know varlist[2] gets me harry, but I could not succeed getting it alone for the for loop.
varlist[2:3]?if w == "harry": do operations...inside for loop. Please specify the input and desired output if it doesn't help, it will help to understand the question better.forandifusing the generator expressions and make it work. I feel this is still a way around. I hope that someone would provide a direct answer for the question.