def global for in yield if else next for in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
>>> a=['', 'a', 'a', '', 'a', '']
>>> b=['b', 'b', 'b']
>>> def f():
global b
for x in b:
yield x
>>> [i if i!='' else f().next() for i in a]
['b', 'a', 'a', 'b', 'a', 'b']
>>>