How to implement decorated generator

Viewed 60

I have some generator:

def my_gen():
    while True:
        #some code
        yield data_chunk

I have some function, which makes some manipulations with data format

def my_formatting_func(data_chunk):
    #some code
    return formated_data_chunk

What the shortest way to create generator which generates data_chunks formatted by my_formatting_func without modifying my_gen?

1 Answers
Related