Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
I have a decorator in a class to be used by that class and by inheriting classes ## class C(object): @staticmethod # With this line enabled or disabled usage in either C or D will be broken. To see that D works remember to remove usage in C def decorateTest(func):

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : I have a decorator in a class Why ? (snip) The exception that I get when using it as a staticmethod and try to use it in the baseclass is TypeError: 'staticmethod' object is not callable. When it is not staticmethod the exception I get in the extension class is is

Re: Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
I've read the Making staticmethod objects callable? thread now, and would have to disagree that all the use cases are strange as stated at http://www.python.org/dev/summary/2006-03-01_2006-03-15/#making-staticmethod-objects-callable In my use case (not the example below) the decorator returns a

Re: Making a decorator a staticmethod

2009-01-08 Thread Jonathan Gardner
On Jan 8, 11:18 am, Zac Burns zac...@gmail.com wrote: In my use case (not the example below) the decorator returns a function of the form def f(self, *args, **kwargs) which makes use of attributes on the instance self. So, it only makes sense to use the staticmethod in the class and in the

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : I've read the Making staticmethod objects callable? thread now, and would have to disagree that all the use cases are strange as stated at http://www.python.org/dev/summary/2006-03-01_2006-03-15/#making-staticmethod-objects-callable In my use case (not the example below)

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Jonathan Gardner a écrit : On Jan 8, 11:18 am, Zac Burns zac...@gmail.com wrote: In my use case (not the example below) the decorator returns a function of the form def f(self, *args, **kwargs) which makes use of attributes on the instance self. So, it only makes sense to use the staticmethod

Re: Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
To Bruno's first e-mail: Everything you said was correct but largely off topic. I did already understand these things as well. To Bruno's second email quote: Nope. He's relying on (part of) the interface(s) implemented by the first argument. The class object itself has nothing to do with is

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : To Bruno's first e-mail: Everything you said was correct but largely off topic. for a definition of off topic equals to didn't fit your expectations. I did already understand these things as well. Sorry - but it was not necessarily obvious from your post, and it's near

Re: Making a decorator a staticmethod

2009-01-08 Thread Carl Banks
On Jan 8, 1:57 pm, Jonathan Gardner jgard...@jonathangardner.net wrote: (Aside: I really can't think of any reason to use staticmethods in Python other than to organize functions into namespaces, and even then, that's what modules are for, right?) In a certain widget toolkit (which I won't