<br><div><span class="gmail_quote">On 3/12/06, <b class="gmail_sendername">Armin Rigo</b> <<a href="mailto:arigo@tunes.org">arigo@tunes.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Staticmethods are for the rare case where you need<br>dynamic class-based dispatch but don't have an instance around.</blockquote></div><br>Actually, I would argue that's what classmethods are for, not staticmethods. You may not envision a desire for having the class in the method right now, but it won't hurt, either. The only real use-case for staticmethods that I know of is one Jp Caldrone pointed out once: storing arbitrary callables as class attributes:
<br><br>class MailHandleThingy(object):<br> sendmail = mymaillib.mailsend<br> ...<br clear="all"><br>Without wrapping that in a staticmethod, 'sendmail' may or may not become a bound method -- and that might change without touching any of the MailHandleThingy code.
<br>All cases where the callable is under your direct control, it's more rewarding (same buck, way more bang) to use classmethods, IMHO.<br><br>(And no, calling a function during class-definition isn't a usecase for staticmethods :)
<br>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org">thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!