Re: Wrapping methods of built-in dict

2009-06-02 Thread shailesh
On May 21, 10:13 pm, George Sakkis wrote: > On May 21, 5:55 pm, shailesh wrote: > > > There doesn't seem to be a predicate returning method wrappers. Is > > there an alternate way to query an object for attributes that are of > > method wrappers? > > Sure:>>> MethodWrapper = type({}.__init__) > >

Re: Wrapping methods of built-in dict

2009-05-21 Thread George Sakkis
On May 21, 5:55 pm, shailesh wrote: > There doesn't seem to be a predicate returning method wrappers. Is > there an alternate way to query an object for attributes that are of > method wrappers? Sure: >>> MethodWrapper = type({}.__init__) >>> isinstance([].__len__, MethodWrapper) True But you'r

Re: Wrapping methods of built-in dict

2009-05-21 Thread shailesh
On May 20, 7:31 pm, Steven D'Aprano wrote: > On Wed, 20 May 2009 18:42:38 -0700, shailesh wrote: > > The reason as far as I understand is that the methods on the built-in > > dict are not of MethodType or FunctionType > > That seems to be true: > > >>> type({}.get) > > >>> type(dict.get> > > > >

Re: Wrapping methods of built-in dict

2009-05-20 Thread I V
On Thu, 21 May 2009 02:31:29 +, Steven D'Aprano wrote: > So the problem isn't directly with getmembers, but with the predicate > functions you have passed to it (inspect.isfunction and inspect.method). > Try inspect.ismethoddescriptor instead. Or perhaps callable ? callable({}.get) and callabl

Re: Wrapping methods of built-in dict

2009-05-20 Thread Steven D'Aprano
On Wed, 20 May 2009 18:42:38 -0700, shailesh wrote: > The reason as far as I understand is that the methods on the built-in > dict are not of MethodType or FunctionType That seems to be true: >>> type({}.get) >>> type(dict.get) > so they are not included in > the result of the inspect.getm

Wrapping methods of built-in dict

2009-05-20 Thread shailesh
Hello, I'm trying to write a class decorator which takes a function as an argument and wraps instancemethods of the class with the function. After reading a few examples on ActiveState and this blog post , my first attempt goes something like this: def tracing_wrapper(fn): import functools