summaryrefslogtreecommitdiffstats
path: root/Doc/library/inspect.rst
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-02-18 03:43:43 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-02-18 03:43:43 (GMT)
commit759bfc6207e7979d4eaeed2a2ae611e1804aef55 (patch)
tree580985dd110d3cdd94b503c881f2f046906fd92c /Doc/library/inspect.rst
parentb169eaa91704a44e350cf66c5e68981964b6764d (diff)
downloadcpython-759bfc6207e7979d4eaeed2a2ae611e1804aef55.zip
cpython-759bfc6207e7979d4eaeed2a2ae611e1804aef55.tar.gz
cpython-759bfc6207e7979d4eaeed2a2ae611e1804aef55.tar.bz2
Issue #1916. Added isgenerator() and isgeneratorfunction() to
inspect.py. Thanks Javi Mansilla for patch review and corrections.
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r--Doc/library/inspect.rst38
1 files changed, 37 insertions, 1 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 7893b69..fb92783 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -28,7 +28,7 @@ Types and members
-----------------
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 @@ attributes:
+-----------+-----------------+---------------------------+-------+
| | 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,6 +275,13 @@ Note:
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)