I am trying to learn python itertools (love it so far!), but I am struck with a problem. I have the following two lists:
a=["http://www.xyz.com/jhuh7287", "http://www.hjuk.com/kashjh716", "http://www.psudjg.com/9279jshkoh", "http://www.xyz.com/jhuh7287", "http://www.xyz.com/9289jhjbg"]
data=["k","some small string here", "so med string here", "some string here","l"]
tempstring="http://www.xyz.com"
Initially, what I wanted was to remove data[i] for all strings which are below a certain length, and subsequently delete the corresponding entries in a. For this, I used something along the lines of:
iselectors = [x is not len(str(x))>1 for x in data]
data=list(itertools.compress(data, iselectors))
a=list(itertools.compress(a, selectors))
..which works well. Now, I need to add another condition to my iselectors, which states that only when "tempstring is in a[i]" and len(str(x))>1..
So, I have tried something like:
iselectors = [tempstring in a and x is not len(str(x))>1 for x in data]
...but I am not sure this is right, since I do not think I am iterating over the entire a when I use "tempstring in a"
Any guidance would be much appreciated. Thanks.