Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
contextlib.closing Class Reference
Inheritance diagram for contextlib.closing:
Inheritance graph
Collaboration diagram for contextlib.closing:
Collaboration graph

List of all members.

Public Member Functions

def __init__
def __enter__
def __exit__

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Context to automatically close something at the end of a block.

Code like this:

    with closing(<module>.open(<arguments>)) as f:

is equivalent to this:

    f = <module>.open(<arguments>)

Definition at line 119 of file

Constructor & Destructor Documentation

def contextlib.closing.__init__ (   self,

Definition at line 136 of file

00137     def __init__(self, thing):
        self.thing = thing

Here is the caller graph for this function:

Member Function Documentation

Definition at line 138 of file

00139     def __enter__(self):
        return self.thing
def contextlib.closing.__exit__ (   self,

Definition at line 140 of file

00141     def __exit__(self, *exc_info):
00142         self.thing.close()

Here is the caller graph for this function:

Member Data Documentation

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 137 of file

The documentation for this class was generated from the following file: