1why the obsession with the ultra-pythonic way of doing things? readability + efficiency trumps "leet hackerz style."
2
3I'd just do it like so:
4
5a = [0,0,1,1,1,0,0,1,0,1,1]
6b = [0,0,0,0,0,0,0,0,0,0,0]
7
8for i in range(len(a)):
9 if a[i] == 1:
10 b[i] = b[i-1] + 1
11 else:
12 b[i] = 0