<?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: Dynamically adding methods with metaprogramming : Ruby and Python</title>
	<atom:link href="http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/</link>
	<description>Code, code and code</description>
	<lastBuildDate>Tue, 28 Jun 2011 21:03:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Anyone for Perl 6 metaprogramming? &#171; transfixed but not dead!</title>
		<link>http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/comment-page-1/#comment-25</link>
		<dc:creator>Anyone for Perl 6 metaprogramming? &#171; transfixed but not dead!</dc:creator>
		<pubDate>Sat, 16 Jan 2010 13:34:15 +0000</pubDate>
		<guid isPermaLink="false">http://codeblog.dhananjaynene.com/?p=44#comment-25</guid>
		<description>[...] all the examples (in Perl 5 / Moose, Ruby, Javascript &amp; Python) I think this one is the most clean and intuitive. Perl 6 has a good future if it keeps this [...]</description>
		<content:encoded><![CDATA[<p>[...] all the examples (in Perl 5 / Moose, Ruby, Javascript &amp; Python) I think this one is the most clean and intuitive. Perl 6 has a good future if it keeps this [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vitaly Babiy</title>
		<link>http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/comment-page-1/#comment-22</link>
		<dc:creator>Vitaly Babiy</dc:creator>
		<pubDate>Fri, 15 Jan 2010 02:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://codeblog.dhananjaynene.com/?p=44#comment-22</guid>
		<description>Awesome post. Metaprogramming doesn&#039;t seem to be used as much in the python world as it is in the ruby world, but it nice to see how to implement these patterns if need be.</description>
		<content:encoded><![CDATA[<p>Awesome post. Metaprogramming doesn&#8217;t seem to be used as much in the python world as it is in the ruby world, but it nice to see how to implement these patterns if need be.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/comment-page-1/#comment-19</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Thu, 14 Jan 2010 18:39:04 +0000</pubDate>
		<guid isPermaLink="false">http://codeblog.dhananjaynene.com/?p=44#comment-19</guid>
		<description>David,

The difference actually is due to the languages per se. python does not allow reopening of a class to add methods to it the way ruby allows.

The entry can be simply removed by using the del command as follows :

&lt;code lang=&quot;python&quot;&gt;
def battle_cry(self):
	print &#039;%s says zing!!!&#039; % self.name
Ninja.battle_cry = battle_cry
# Remove the battle_cry entry 
del battle_cry
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>The difference actually is due to the languages per se. python does not allow reopening of a class to add methods to it the way ruby allows.</p>
<p>The entry can be simply removed by using the del command as follows :</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> battle_cry<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%s says zing!!!'</span> % <span style="color: #008000;">self</span>.<span style="color: black;">name</span><br />
Ninja.<span style="color: black;">battle_cry</span> <span style="color: #66cc66;">=</span> battle_cry<br />
<span style="color: #808080; font-style: italic;"># Remove the battle_cry entry </span><br />
<span style="color: #ff7700;font-weight:bold;">del</span> battle_cry</div></td></tr></tbody></table></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Bacher</title>
		<link>http://codeblog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/comment-page-1/#comment-18</link>
		<dc:creator>David Bacher</dc:creator>
		<pubDate>Thu, 14 Jan 2010 17:50:09 +0000</pubDate>
		<guid isPermaLink="false">http://codeblog.dhananjaynene.com/?p=44#comment-18</guid>
		<description>That&#039;s an interesting comparison. Could you contrast the ruby and python approaches in more detail? One thing that strikes me is namespace issues. It looks like your python code ends up defining functions in the global namespace and then assigning them to a class or instance, while the ruby code scopes the definitions more explicitly.</description>
		<content:encoded><![CDATA[<p>That&#8217;s an interesting comparison. Could you contrast the ruby and python approaches in more detail? One thing that strikes me is namespace issues. It looks like your python code ends up defining functions in the global namespace and then assigning them to a class or instance, while the ruby code scopes the definitions more explicitly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

