Index: Lib/test/test_inspect.py =================================================================== --- Lib/test/test_inspect.py (revision 60647) +++ Lib/test/test_inspect.py (working copy) @@ -42,10 +42,10 @@ self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp)) class TestPredicates(IsTestBase): - def test_thirteen(self): + def test_fifteen(self): count = len(filter(lambda x:x.startswith('is'), dir(inspect))) - # Doc/lib/libinspect.tex claims there are 13 such functions - expected = 13 + # Doc/library/inspect.rst claims there are 15 such functions + expected = 15 err_msg = "There are %d (not %d) is* functions" % (count, expected) self.assertEqual(count, expected, err_msg) Index: Doc/library/inspect.rst =================================================================== --- Doc/library/inspect.rst (revision 60647) +++ Doc/library/inspect.rst (working copy) @@ -28,7 +28,7 @@ ----------------- The :func:`getmembers` function retrieves the members of an object such as a -class or module. The eleven functions whose names begin with "is" are mainly +class or module. The fifteen functions whose names begin with "is" are mainly provided as convenient choices for the second argument to :func:`getmembers`. They also help you determine when you can expect to find the following special attributes: @@ -81,6 +81,35 @@ +-----------+-----------------+---------------------------+-------+ | | func_name | (same as __name__) | | +-----------+-----------------+---------------------------+-------+ +| generator | __iter__ | defined to support | | +| | | iteration over container | | ++-----------+-----------------+---------------------------+-------+ +| | close | raises new GeneratorExit | | +| | | exception inside the | | +| | | generator to terminate | | +| | | the iteration | | ++-----------+-----------------+---------------------------+-------+ +| | gi_code | code object | | ++-----------+-----------------+---------------------------+-------+ +| | gi_frame | frame object or possibly | | +| | | None once the generator | | +| | | has been exhausted | | ++-----------+-----------------+---------------------------+-------+ +| | gi_running | set to 1 when generator | | +| | | is executing, 0 otherwise | | ++-----------+-----------------+---------------------------+-------+ +| | next | return the next item from | | +| | | the container | | ++-----------+-----------------+---------------------------+-------+ +| | send | resumes the generator and | | +| | | "sends" a value that | | +| | | becomes the result of the | | +| | | current yield-expression | | ++-----------+-----------------+---------------------------+-------+ +| | throw | used to raise an | | +| | | exception inside the | | +| | | generator | | ++-----------+-----------------+---------------------------+-------+ | traceback | tb_frame | frame object at this | | | | | level | | +-----------+-----------------+---------------------------+-------+ @@ -246,7 +275,14 @@ Return true if the object is a Python function or unnamed (:term:`lambda`) function. +.. function:: isgeneratorfunction(object) + Return true if the object is a Python generator function. + +.. function:: isgenerator(object) + + Return true if the object is a generator. + .. function:: istraceback(object) Return true if the object is a traceback.