#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# author: bigfoolliu


"""
yield from使用

https://www.cnblogs.com/wongbingming/p/9085268.html

1.yield from后面加上可迭代对象，他可以把可迭代对象里的每个元素一个一个的yield出来，对比yield来说代码更加简洁，结构更加清晰
2.当 yield from 后面加上一个生成器后，就实现了生成的嵌套
"""


def generator(*args, **kwargs):
    for item in args:
        yield from item


def yield_from_demo():
    names = ['liu', 'liu1', 'liu2']
    ages = [10, 20, 30]
    print(list(generator(names, ages)))  # ['liu', 'liu1', 'liu2', 10, 20, 30]


if __name__ == '__main__':
    yield_from_demo()
