1# construct a bytes object from a generator
2def gen():
3    for i in range(4):
4        yield i
5print(bytes(gen()))
6