【发布时间】:2012-07-30 22:50:10
【问题描述】:
在生成器函数中,我怎样才能知道它是否已经产生了任何东西?
def my_generator(stuff):
# complex logic that interprets stuff and may or may not yield anything
# I only want to yield this if nothing has been yielded yet.
yield 'Nothing could be done with the input.'
【问题讨论】: