[Python-Dev] how to inspect if something includes a bound first param
Terry Reedy
tjreedy at udel.edu
Wed Feb 25 04:25:29 CET 2015
On 2/24/2015 9:02 PM, Eric V. Smith wrote:
> I'm not sure if it's correct, but deep in a library of mine I have:
>
> elif type(fn) == types.MethodType:
> # bound method?
> if fn.im_self is None:
> # no 'self'
> nskip = 0
> else:
> # need to supply 'self'
> nskip = 1
>
> This is also a 2.x library. No idea if it works with 3.x.
It will not. 3.x does not have 'unbound methods' in the above sense,
and for bound methods, fn.im_self is now fn.__self__.
--
Terry Jan Reedy
More information about the Python-Dev
mailing list