On 3/12/06, Armin Rigo <[EMAIL PROTECTED]> wrote:
Staticmethods are for the rare case where you need
dynamic class-based dispatch but don't have an instance around.
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:
class MailHandleThingy(object):
sendmail = mymaillib.mailsend
...
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.
All cases where the callable is under your direct control, it's more rewarding (same buck, way more bang) to use classmethods, IMHO.
(And no, calling a function during class-definition isn't a usecase for staticmethods :)
--
Thomas Wouters <[EMAIL PROTECTED]>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com