Unbound methods and functions

Michele Simionato michele.simionato at poste.it
Fri Nov 28 13:52:31 EST 2003


Ben <ben at transversal.com> wrote in message news:<3fc60223$0$27468$afc38c87 at news.easynet.co.uk>...
> 
> Arrgh, forgot to ask the question that was the entire point of the post
> 
> Is there any real difference between an unbound method, and a function,
> apart from the scoping differences. I.e would it make any difference in the
> get descriptor for a function, when called on a type, returned the function
> instead of an unbound method?
> 
> Cheers
> 
> Ben
> ---

I do not really understand your question. Of course an unbound method
is different from a function, even if you can convert one in the other.
For instance, if you are inspecting code (for automatic generation of
documentation, or for metaprogramming purposes) the two things are
different: you get one with inspect.isfunction, the other with
inspect.ismethod. There are other differences too. Look at the source
code of the inspect module for more. I think you already know the standard
reference on descriptors:

           http://users.rcn.com/python/download/Descriptor.htm




More information about the Python-list mailing list