<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python Gotchas 1: __del__ is not the opposite of __init__</title>
	<atom:link href="http://www.algorithm.co.il/blogs/programming/python/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/</link>
	<description>Algorithms, for the heck of it</description>
	<lastBuildDate>Tue, 21 Jun 2011 21:07:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: B.Moore</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-268</link>
		<dc:creator>B.Moore</dc:creator>
		<pubDate>Thu, 14 Jan 2010 23:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-268</guid>
		<description>It seems to me that the __del__ function must have a purpose and be necessary, otherwise why would the people who maintain and develop python keep the function around.

I encountered this issue today and thanks to this article I resolved my problem.  I realize now the proper way to use the __del__ deconstructor would have been to initialize all of the properties that I would be affecting on the first lines in the __init__ constructor.

If I were a better coder and followed the most primitive standard of declaring and initializing variables first and at the top of my code I would&#039;t have seen this issue at all.

Anyway good post and great commentary from everyone ;-)</description>
		<content:encoded><![CDATA[<p>It seems to me that the __del__ function must have a purpose and be necessary, otherwise why would the people who maintain and develop python keep the function around.</p>
<p>I encountered this issue today and thanks to this article I resolved my problem.  I realize now the proper way to use the __del__ deconstructor would have been to initialize all of the properties that I would be affecting on the first lines in the __init__ constructor.</p>
<p>If I were a better coder and followed the most primitive standard of declaring and initializing variables first and at the top of my code I would&#8217;t have seen this issue at all.</p>
<p>Anyway good post and great commentary from everyone ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dormar</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-267</link>
		<dc:creator>Dormar</dc:creator>
		<pubDate>Tue, 27 Oct 2009 20:55:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-267</guid>
		<description>Couldn&#039;t stress enough how much __del__ is unnecessary in most cases.
95% of python OO code I CR has unnecessary and possibly buggy __del__s.
And not to even BEGIN talking about reference cycles and the problem you have with __del__&#039;s in that case.
Anyway - would love if you stress about it in a post :)</description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t stress enough how much __del__ is unnecessary in most cases.<br />
95% of python OO code I CR has unnecessary and possibly buggy __del__s.<br />
And not to even BEGIN talking about reference cycles and the problem you have with __del__&#8217;s in that case.<br />
Anyway &#8211; would love if you stress about it in a post :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nirs</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-266</link>
		<dc:creator>nirs</dc:creator>
		<pubDate>Thu, 22 Oct 2009 21:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-266</guid>
		<description>Good idea about class attributes here - it can clean up lot of code and even save lot of uninteresting __init__ implementations.</description>
		<content:encoded><![CDATA[<p>Good idea about class attributes here &#8211; it can clean up lot of code and even save lot of uninteresting __init__ implementations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rmn</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-265</link>
		<dc:creator>rmn</dc:creator>
		<pubDate>Thu, 22 Oct 2009 16:38:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-265</guid>
		<description>nice one, it actually makes sense - and important to know :)</description>
		<content:encoded><![CDATA[<p>nice one, it actually makes sense &#8211; and important to know :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shai</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-264</link>
		<dc:creator>Shai</dc:creator>
		<pubDate>Thu, 22 Oct 2009 09:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-264</guid>
		<description>@nirs:

You really can&#039;t be sure __init__ runs through anything. The exception that caused it to exit in mid-execution could have been KeyboardInterrupt. If you want defaults, they are better defined as class attributes, so that they&#039;re available to any instance; but better yet, is to do what the post says, and avoid __del__.</description>
		<content:encoded><![CDATA[<p>@nirs:</p>
<p>You really can&#8217;t be sure __init__ runs through anything. The exception that caused it to exit in mid-execution could have been KeyboardInterrupt. If you want defaults, they are better defined as class attributes, so that they&#8217;re available to any instance; but better yet, is to do what the post says, and avoid __del__.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nirs</title>
		<link>http://www.algorithm.co.il/blogs/programming/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/#comment-263</link>
		<dc:creator>nirs</dc:creator>
		<pubDate>Tue, 20 Oct 2009 20:17:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=438#comment-263</guid>
		<description>It is best to either define all variables in __init__ with a default value before doing anything else, or in other methods, use getattr(self, &#039;name&#039;) when accessing attributes, to avoid attribute errors.</description>
		<content:encoded><![CDATA[<p>It is best to either define all variables in __init__ with a default value before doing anything else, or in other methods, use getattr(self, &#8216;name&#8217;) when accessing attributes, to avoid attribute errors.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

