<?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: Constructor / Method overloading in Python using Function Switching</title>
	<atom:link href="http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=constructor-method-overloading-in-python</link>
	<description>Dhananjay Nene's opinions on software programming, design, architecture and the internet</description>
	<lastBuildDate>Sun, 22 Jan 2012 06:53:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Heraldo Rodriguez</title>
		<link>http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/comment-page-1/#comment-5277</link>
		<dc:creator>Heraldo Rodriguez</dc:creator>
		<pubDate>Fri, 27 Mar 2009 20:41:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=583#comment-5277</guid>
		<description>with adapter i mean this;

class InterfaceAdapter(object):
    &quot;&quot;&quot;Adapts an objet to adhere to the contract defined by an interface
    in this case only one function, interface_func 
    but could be N attributes and Methods &quot;&quot;&quot;
    def __init__(self, obj, func):
        &quot;&quot;&quot;Pass in the function to use as &#039;interface_func&#039;&quot;&quot;&quot;
        self.interface_obj = obj
        self.interface_func = func

    def __getattr__(self, attr):
        &quot;&quot;&quot;Everything else is delegated to the object&quot;&quot;&quot;
        return getattr(self.interface_obj, attr)</description>
		<content:encoded><![CDATA[<p>with adapter i mean this;</p>
<p>class InterfaceAdapter(object):<br />
    &#8220;&#8221;"Adapts an objet to adhere to the contract defined by an interface<br />
    in this case only one function, interface_func<br />
    but could be N attributes and Methods &#8220;&#8221;"<br />
    def __init__(self, obj, func):<br />
        &#8220;&#8221;"Pass in the function to use as &#8216;interface_func&#8217;&#8221;"&#8221;<br />
        self.interface_obj = obj<br />
        self.interface_func = func</p>
<p>    def __getattr__(self, attr):<br />
        &#8220;&#8221;"Everything else is delegated to the object&#8221;"&#8221;<br />
        return getattr(self.interface_obj, attr)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heraldo Rodriguez</title>
		<link>http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/comment-page-1/#comment-5276</link>
		<dc:creator>Heraldo Rodriguez</dc:creator>
		<pubDate>Fri, 27 Mar 2009 20:28:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=583#comment-5276</guid>
		<description>I am new to Python ( so perhaps i am still influenced by Java) but , why not to use an adapter ( in python is very easy to implement the pattern using the __getattr__ magic, what is more, we can make a GENERAL adapter for N classes without needing to add code for future new classes we need to adapt ) The method has a contract or interface well defined , despite of python duck typing is solving this for us ( we need to provide it with age,name and last_name) so we could wrap the hash , the list or whatever with the adapter that honor the contract and that would do the trick.</description>
		<content:encoded><![CDATA[<p>I am new to Python ( so perhaps i am still influenced by Java) but , why not to use an adapter ( in python is very easy to implement the pattern using the __getattr__ magic, what is more, we can make a GENERAL adapter for N classes without needing to add code for future new classes we need to adapt ) The method has a contract or interface well defined , despite of python duck typing is solving this for us ( we need to provide it with age,name and last_name) so we could wrap the hash , the list or whatever with the adapter that honor the contract and that would do the trick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/comment-page-1/#comment-5169</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Wed, 25 Mar 2009 12:50:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=583#comment-5169</guid>
		<description>@Parag,

It allows one to model a different function for handling different types. Thats a cleanliness I did like about it. I can believe this structuring is likely to become only more helpful as one starts modeling other constructs such as Monad approximations. However your thoughts are very much appropriate as well. As per the scope described of a simple functionality, I would go with whatever good taste suggests.</description>
		<content:encoded><![CDATA[<p>@Parag,</p>
<p>It allows one to model a different function for handling different types. Thats a cleanliness I did like about it. I can believe this structuring is likely to become only more helpful as one starts modeling other constructs such as Monad approximations. However your thoughts are very much appropriate as well. As per the scope described of a simple functionality, I would go with whatever good taste suggests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parag Shah</title>
		<link>http://blog.dhananjaynene.com/2009/03/constructor-method-overloading-in-python/comment-page-1/#comment-5161</link>
		<dc:creator>Parag Shah</dc:creator>
		<pubDate>Wed, 25 Mar 2009 08:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=583#comment-5161</guid>
		<description>Hi Dhananjay,

If I understand correctly the inner functions essentially replace 3 if..else..if blocks

I am just thinking aloud, but is this significantly more readable or maintainable than having if..else blocks in the constructor?</description>
		<content:encoded><![CDATA[<p>Hi Dhananjay,</p>
<p>If I understand correctly the inner functions essentially replace 3 if..else..if blocks</p>
<p>I am just thinking aloud, but is this significantly more readable or maintainable than having if..else blocks in the constructor?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.617 seconds -->

