<?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: Progress with Python Decorators and Meta Classes</title>
	<atom:link href="http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/</link>
	<description>Where the urethane hits the pavement</description>
	<lastBuildDate>Fri, 10 Sep 2010 12:37:53 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: J5</title>
		<link>http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/comment-page-1/#comment-1336</link>
		<dc:creator>J5</dc:creator>
		<pubDate>Fri, 22 Apr 2005 04:57:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.martianrock.com/?p=48#comment-1336</guid>
		<description>Ah, excelent.  No reason for the function.  I think I  needed some coffee at that point ;-)  Now that I see how this all fits together it looks like I have everything I need to do what I want.  Thanks for all the info.  </description>
		<content:encoded><![CDATA[<p>Ah, excelent.  No reason for the function.  I think I  needed some coffee at that point <img src='http://www.j5live.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Now that I see how this all fits together it looks like I have everything I need to do what I want.  Thanks for all the info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/comment-page-1/#comment-1335</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 22 Apr 2005 04:38:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.martianrock.com/?p=48#comment-1335</guid>
		<description>Note that you can assign arbitrary attributes to a function, so in your method() decorator, you could just as easily pass through the original function object, setting _dbus_method_name on it.

Also, is there any reason for attaching a function to the method object, rather than just attaching the information directly as an attribute?  I&#039;d probably do something like &quot;func.is_dbus_method = True&quot;, then in your metaclass check if getattr(func, &#039;is_dbus_method&#039;, False) is true.</description>
		<content:encoded><![CDATA[<p>Note that you can assign arbitrary attributes to a function, so in your method() decorator, you could just as easily pass through the original function object, setting _dbus_method_name on it.</p>
<p>Also, is there any reason for attaching a function to the method object, rather than just attaching the information directly as an attribute?  I&#8217;d probably do something like &#8220;func.is_dbus_method = True&#8221;, then in your metaclass check if getattr(func, &#8216;is_dbus_method&#8217;, False) is true.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J5</title>
		<link>http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/comment-page-1/#comment-1334</link>
		<dc:creator>J5</dc:creator>
		<pubDate>Fri, 22 Apr 2005 03:39:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.martianrock.com/?p=48#comment-1334</guid>
		<description>No reason for not passing keywords.  This was just a quick hack so I could wrap my head around decorators and metaclasses.  I wanted to brainstorm the design and see how things could possibly fit together.   I think with the try/except block I&#039;m just going to get the function object&#039;s dictionary and do a has_key().  It is much cleaner that way.  Also I don&#039;t think I will need a function there and will instead pass in some structured data.  </description>
		<content:encoded><![CDATA[<p>No reason for not passing keywords.  This was just a quick hack so I could wrap my head around decorators and metaclasses.  I wanted to brainstorm the design and see how things could possibly fit together.   I think with the try/except block I&#8217;m just going to get the function object&#8217;s dictionary and do a has_key().  It is much cleaner that way.  Also I don&#8217;t think I will need a function there and will instead pass in some structured data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.j5live.com/2005/04/21/progress-with-python-decorators-and-meta-classes/comment-page-1/#comment-1333</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 22 Apr 2005 00:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.martianrock.com/?p=48#comment-1333</guid>
		<description>&lt;code&gt;&lt;pre&gt;
def method(func):
    def decorator(self, *args):
        func(self, *args)
	
    def _dbus_method_name():
        return func.__name__
	
    decorator._dbus_method_name = _dbus_method_name
    return decorator
&lt;/pre&gt;&lt;/code&gt;

Don&#039;t forget to return the value of func(self, *args)!  Also, is it intentional to accept *args but not **kwargs?

&lt;code&gt;&lt;pre&gt;
        method_list = []
        for func in dct.values():
	    try:
	        method_name = func._dbus_method_name()
	        method_list.append(method_name)
            except:
                pass 
&lt;/pre&gt;&lt;/code&gt;

Yeah I don&#039;t like the try-except here either.  Changing it to be an &quot;except AttributeError&quot; would help a little, but it would be best as:

&lt;code&gt;&lt;pre&gt;
	    try:
	        dbus_method_name = func._dbus_method_name
            except AttributeError:
                pass 
            else:
	        method_list.append(dbus_method_name())
&lt;/pre&gt;&lt;/code&gt;
</description>
		<content:encoded><![CDATA[<p><code>
<pre>
def method(func):
    def decorator(self, *args):
        func(self, *args)

    def _dbus_method_name():
        return func.__name__

    decorator._dbus_method_name = _dbus_method_name
    return decorator
</pre>
<p></code></p>
<p>Don&#8217;t forget to return the value of func(self, *args)!  Also, is it intentional to accept *args but not **kwargs?</p>
<p><code>
<pre>
        method_list = []
        for func in dct.values():
	    try:
	        method_name = func._dbus_method_name()
	        method_list.append(method_name)
            except:
                pass
</pre>
<p></code></p>
<p>Yeah I don&#8217;t like the try-except here either.  Changing it to be an &#8220;except AttributeError&#8221; would help a little, but it would be best as:</p>
<p><code>
<pre>
	    try:
	        dbus_method_name = func._dbus_method_name
            except AttributeError:
                pass
            else:
	        method_list.append(dbus_method_name())
</pre>
<p></code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
