What is the name of the technique where there is a conditional is used in an index for a list but the variable in the conditional is a list itself? As you can see a
is a list but it is used to check for corresponding elements in the list b
.
>>> a = [ 1, 2, 3]
>>> b = [7, 7,7]
>>> b[a==1] = 8
>>> b
[8, 7, 7]
I was writing code using numpy arrays and thought of seeing if core Python included the same feature and it turns out it exists. I just had no way of searching for it because I didn't have the slightest idea of what it is called.
EDIT: I would like to know what is called and also an explanation of what is going on given the comments indicate that the code isn't doing what I think it is doing.
For clarity and elaboration, this is the code that I entered for numpy and got replacement similar to the Python list.
>>> import numpy as np
>>> lower_green = np.array([0,180,0])
>>> upper_green = np.array([100,255,100])
>>> upper_green[lower_green == 0] = 7
>>> upper_green
array([ 7, 255, 7])