def is_generator_function(obj):
CO_GENERATOR = <NUM_LIT><EOL>return bool(((inspect.isfunction(obj) or inspect.ismethod(obj)) and<EOL>obj.__code__.co_flags & CO_GENERATOR))<EOL>
Return true if the object is a user-defined generator function.

    Generator function objects provides same attributes as functions.
    See isfunction.__doc__ for attributes listing.

    Adapted from Python 2.6.

    Args:
      obj: an object to test.

    Returns:
      true if the object is generator function.