dimanche 13 mai 2018

Conditional skip of code lines

I have a time_slots list of sublists, which looks like this:

[[(37913.0, 0.3104248046875),
(37917.0, 0.3106689453125),
(37919.0, 0.31201171875)],
[(37945.0, 0.3123779296875), (37947.0, 0.31201171875)],
[],
[(37977.0, 0.311279296875),
(37979.0, 0.310791015625),
(37981.0, 0.3106689453125)],
[(38008.0, 0.31103515625),
(38011.0, 0.31005859375),
(38012.0, 0.3109130859375)],
[],
[(38039.0, 0.3095703125),
(38042.0, 0.3101806640625),
(38044.0, 0.3123779296875)],
[],
[],

I am applying a for loop on time_slots array which is like:

for y in range(0,len(time_slots)):

    x_points,y_points = zip(*time_slots[y])
    inrplt_func = interpolate.CubicSpline(x_points,y_points)

Notice that there are empty lists in time_slots (e.g 3rd and 6th elements). What i want to do is tuple unpacking line if list is empty I know i can use break but i don't want leave loop.

Aucun commentaire:

Enregistrer un commentaire