On Fri, Mar 11, 2011 at 10:48 PM, Guido van Rossum <gu...@python.org> wrote: >> +1 on making staticmethods callable. I would have found that useful in the >> past. > > IIUC Thomas found that this breaks some current use of staticmethod.
>From his first post, I understood the compatibility issue to more be the fact that even if we make it callable, it still needs to return the underlying function from __get__ rather than itself. So making it callable didn't break anything, but changing the behaviour of __get__ did. So long as people follow the policy of applying staticmethod() when stashing things they don't want to turn into methods in class namespaces, that should be fine. The difference between @staticmethod and a "@nondescriptor" decorator that mimics CFunction behaviour would then largely be in whether or not they implemented __get__ at all. >>> hasattr(len, "__get__") False >>> hasattr(staticmethod(len), "__get__") True >>> staticmethod(len).__get__(type) is len True >>> set(dir(len)) - set(dir(staticmethod(len))) {'__call__', '__name__', '__module__', '__self__'} >>> set(dir(staticmethod(len))) - set(dir(len)) {'__func__', '__get__'} Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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