<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>t+1 - Latest Comments in Now I have a reason to use staticmethod</title><link>http://tplus1.disqus.com/</link><description></description><atom:link href="https://tplus1.disqus.com/now_i_have_a_reason_to_use_staticmethod/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 03 Sep 2008 01:24:22 -0000</lastBuildDate><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-2026924</link><description>&lt;p&gt;Nice post.  I was wondering about some good uses for staticmethod.&lt;/p&gt;&lt;p&gt;Thanks,&lt;br&gt;Paul&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">PaulHildebrandt</dc:creator><pubDate>Wed, 03 Sep 2008 01:24:22 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1976021</link><description>&lt;p&gt;Awesome... I've been asking myself the very same question for a long time.. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nicolas Miyasato (miya)</dc:creator><pubDate>Mon, 01 Sep 2008 09:20:38 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1942399</link><description>&lt;p&gt;Yep, it could still mangle the parameters. I think I do that in a few places. The main benefit for me is that I can glance at a class and say "Ok, I know that all actual changes to this object are isolated to these two non-static methods."&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary Bernhardt</dc:creator><pubDate>Sun, 31 Aug 2008 15:27:36 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1940979</link><description>&lt;p&gt;Hey Gary,&lt;/p&gt;&lt;p&gt;I like the idea of using staticmethod as an annotation to make it clear that the method doesn't alter the class.  It could still have side effects though; it could mangle the parameters passed in, right?&lt;/p&gt;&lt;p&gt;Matt&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Wilson</dc:creator><pubDate>Sun, 31 Aug 2008 13:00:09 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1940969</link><description>&lt;p&gt;Hi Pete,  Thanks for the comment.&lt;/p&gt;&lt;p&gt;Could dict.fromkeys also be implemented as a classmethod?  I make alternate constructors all the time, but I make them classmethods, so that I still have a reference to the class that I want to make instances out of.&lt;/p&gt;&lt;p&gt;When I subclass a dict, then call fromkeys on my subclass, it returns an instance of my subclass.  I don't see how that would work with a staticmethod, since it doesn't seem to have any association with the class.&lt;/p&gt;&lt;p&gt;I'm not sure I understand what you mean about how large libraries don't know the module of every class.  Is it the case where module B imports a class from module A, and then another module C imports that class from module B?  In that case, I can definitely see the merit of bundling all related code together in the class.&lt;/p&gt;&lt;p&gt;I'm not against staticmethods.  I just never could see myself using them.&lt;/p&gt;&lt;p&gt;Matt&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Wilson</dc:creator><pubDate>Sun, 31 Aug 2008 12:59:07 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1940690</link><description>&lt;p&gt;If you've ever used dict.fromkeys you are using a staticmethod. (Although it is implemented on the C side, so a little different). Hopefully this shows an example of another place staticmethod is great; alternate constructors.&lt;/p&gt;&lt;p&gt;Larger libraries don't always have the luxury of knowing the module for every class that gets passed around. Using the static methods allows the entire api to travel around with the class description. This is a huge convenience. It is definitely for more than "make java people comfortable."&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Shinners</dc:creator><pubDate>Sun, 31 Aug 2008 12:26:32 -0000</pubDate></item><item><title>Re: Now I have a reason to use staticmethod</title><link>http://blog.tplus1.com/blog/2008/08/31/now-i-have-a-reason-to-use-staticmethod/#comment-1940316</link><description>&lt;p&gt;I use staticmethod to indicate that a method has no side effects (you can't modify self if it doesn't even get passed in). Using it to replace methods is interesting, but I always find that such things are non-obvious when I go back to the code after six months. I can think of a few situations in testing where it would've been quite useful, though.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary Bernhardt</dc:creator><pubDate>Sun, 31 Aug 2008 11:37:36 -0000</pubDate></item></channel></rss>