On Thu, 07 May 2009 00:39:28 -0400, Terry Reedy wrote:

> Functions that refer to neither the class nor an instance thereof can
> usually be moved outside the class altogether.  Python is not Java.  I
> believe staticmethod() was mainly added because it is needed for
> .__new__(), at least in some appearances.


Can be, but if there's reason enough to keep it with a class, there's no 
reason not to. Sometimes I have a class with a few methods that share 
common code, but that code happens to not include self (or cls). Since 
the common code is only of interest to that class, even though it doesn't 
need the instance, I factor the common code out into a method.

This would be a good candidate for a staticmethod, only due to laziness I 
don't usually bother :)


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to