Skip to content Skip to sidebar Skip to footer

Connect String Value To A Corresponding Variable Name

This question has somehow to do with an earlier post from me. See here overlap-of-nested-lists-creates-unwanted-gap I think that I have found a solution but i can't figure out how

Solution 1:

I managed to solve it using the iterator i. See the fiddle from my original post in order to comprehend what I did with the following piece of code:

if i < 0:
    cond = 0else:
    cond = ipred_axis= data_j[cond]['axis']      

ifpred_axis== 'x':
    g = 0elifpred_axis== 'y':
    g = 1elifpred_axis== 'z':
    g = 2   

calc_size = len(ag[g])
n_offset = calc_size+offset

I haven't figured yet why cond must be i and not i-1 but it works. As soon as I figure out the logic behind it I will post it.

EDIT: It doesn't work for i it works for i-1. My indices for the relevant list start at 1. ag[0] is reserved for a constant which can be added if necessary for further calculations. So since the relevant indices are moved up by the value of 1 from the beginning already i don't need to decrease the iterator in each run.

Post a Comment for "Connect String Value To A Corresponding Variable Name"