I have the following list
bar = [\'a\',\'b\',\'c\',\'x\',\'y\',\'z\']
What I want to do is to assign 1st, 4th and 5th values of bar>
Yet another method:
from itertools import compress
bar = ['a','b','c','x','y','z']
v1, v2, v3 = compress(bar, (1, 0, 0, 1, 1, 0))
In addition, you can ignore length of the list and skip zeros at the end of selectors:
v1, v2, v3 = compress(bar, (1, 0, 0, 1, 1,))
https://docs.python.org/2/library/itertools.html#itertools.compress