>>> import inspect>>> >>> def foo():... return 'foo'... >>> def bar():... yield 'bar'... >>> print inspect.isgeneratorfunction(foo)False>>> print inspect.isgeneratorfunction(bar)True
- Python 2.6版的新功能

>>> import inspect>>> >>> def foo():... return 'foo'... >>> def bar():... yield 'bar'... >>> print inspect.isgeneratorfunction(foo)False>>> print inspect.isgeneratorfunction(bar)True