Skip to content

Commit 5ad6108

Browse files
committed
Issue #44 as a commit
1 parent a0603f0 commit 5ad6108

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

magicmethods.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ \section{Construction and Initialization}
4141
\item[\code{__init__(self, [...)}]
4242
The initializer for the class. It gets passed whatever the primary constructor was called with (so, for example, if we called \code{x = SomeClass(10, 'foo')}, \code{__init__} would get passed \code{10} and \code{'foo'} as arguments. \code{__init__} is almost universally used in Python class definitions.
4343
\item[\code{__del__(self)}]
44-
If \code{__new__} and \code{__init__} formed the constructor of the object, \code{__del__} is the destructor. It doesn't implement behavior for the statement \code{del x} (so that code would not translate to \code{x.__del__()}). Rather, it defines behavior for when an object is garbage collected. It can be quite useful for objects that might require extra cleanup upon deletion, like sockets or file objects. Be careful, however, as there is no guarantee that \code{__del__} will be executed if the object is still alive when the interpreter exits, so \code{__del__} can't serve as a replacement for good coding practices (like always closing a connection when you're done with it. In fact, \code{__del__} should almost never be used because of the precarious circumstances under which it is called; use it with caution!
44+
If \code{__new__} and \code{__init__} formed the constructor of the object, \code{__del__} is the destructor. It doesn't implement behavior for the statement \code{del x} (so that code would not translate to \code{x.__del__()}). Rather, it defines behavior for when an object is garbage collected. It can be quite useful for objects that might require extra cleanup upon deletion, like sockets or file objects. Be careful, however, as there is no guarantee that \code{__del__} will be executed if the object is still alive when the interpreter exits, so \code{__del__} can't serve as a replacement for good coding practices (like always closing a connection when you're done with it). In fact, \code{__del__} should almost never be used because of the precarious circumstances under which it is called; use it with caution!
4545

4646
\end{description}
4747

0 commit comments

Comments
 (0)