Make staticmethod objects callable?
Steven Bethard
steven.bethard at gmail.com
Tue Feb 28 16:57:46 EST 2006
Nicolas Fleury wrote:
> I was wondering if it would make sense to make staticmethod objects
> callable, so that the following code would work:
>
> class A:
> @staticmethod
> def foo(): pass
> bar = foo()
Do you have a real-world use case? I pretty much never use
staticmethods (preferring instead to use module-level functions) so I'm
having a hard time coming up with some code where this would be really
useful. I'm also a little wary of breaking the parallel between
classmethod and staticmethod which are currently *just* descriptors
(without any other special functionality).
Maybe instead of making just staticmethods callable, both staticmethods
and classmethods could gain an 'im_func' attribute like bound and
unbound methods have?
STeVe
More information about the Python-list
mailing list