Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Greg Ewing
Anthony Tolle wrote: > As for a more concrete example, imagine the wrapper using the inspect > module to gather some information about the stack frame and passing it > along to selected methods. That's still not very concrete. It doesn't demonstrate why you would want to find out that particular p

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Greg Ewing
Phillip J. Eby wrote: > He's writing a variant of 'partial' that inserts an argument *after* > the 'self', if there is one I'll need convincing that the user of such a function isn't able to know whether the function he's wrapping takes a self, and use an appropriate variation of the partial func

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Greg Ewing
Anthony Tolle wrote: > So how does wrapper1 know whether it is wrapping a static method, a > bound method, or an unbound method? Well, one way it could do this is > to examine the type of the descriptor it is wrapping. No, a wrapper can't distinguish between a plain function and an unbound metho

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Greg Ewing
Nick Coghlan wrote: > functools.partial style functionality doesn't always play well > with methods, I can see it not working well with *unbound* methods. Bound methods shouldn't be any problem, since from the outside they're called just like any other function. But applying partial to an unboun

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Anthony Tolle
On Sun, Mar 9, 2008 at 6:31 AM, Greg Ewing <[EMAIL PROTECTED]> wrote: > > No, a wrapper can't distinguish between a plain function and > an unbound method this way, because it gets called before the > function is put into a class. So it's always wrapping a plain > function, not an unbound metho

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Anthony Tolle
On Sun, Mar 9, 2008 at 7:53 PM, Anthony Tolle <[EMAIL PROTECTED]> wrote: > On Sun, Mar 9, 2008 at 6:31 AM, Greg Ewing <[EMAIL PROTECTED]> wrote: > > > > No, a wrapper can't distinguish between a plain function and > > an unbound method this way, because it gets called before the > > function

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Anthony Tolle
On Sun, Mar 9, 2008 at 5:54 AM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Anthony Tolle wrote: > > As for a more concrete example, imagine the wrapper using the inspect > > module to gather some information about the stack frame and passing it > > along to selected methods. > > That's still not v

Re: [Python-3000] The case for unbound methods?

2008-03-09 Thread Anthony Tolle
On Sat, Mar 8, 2008 at 8:38 PM, Steven Bethard <[EMAIL PROTECTED]> wrote: > > I don't see an error thrown with either the bound or unbound methods... > Sorry, I should have clarified. The error occurs when wrapping the function as a descriptor, not when wrapping it with another function. Here's a