def iset(iterable):
    for i, x in enumerate(iterable):

        def setter(value):
            iterable[i] = value
yield setter, x
a = list(range(10))
for set_x, x in iset(a):
    set_x(x * 2)
print(a)
How to modify elements of iterables with iterators? I.e. how to get write-iterators in Python?