Method / Functions - What are the differences?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Mar 2 03:57:52 EST 2010


John Posner a écrit :
> On 3/1/2010 2:59 PM, Bruno Desthuilliers wrote:
> 
>> Answer here:
>>
>> http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/bd71264b6022765c/3a77541bf9d6617d#doc_89d608d0854dada0 
>>
>>
>> I really have to put this in the wiki :-/
> 
> 
> Bruno, I performed a light copy-edit of your writeup and put in some 
> reStructuredText (reST) markup. The result is at:
> 
>   http://cl1p.net/bruno_0301.rst/

Cool.

> 
> The only sentence that I think needs work is:
> 
>   Having access to itself (of course), the
>   instance (if there's one) and the class, it's easy for it
>   to wrap all this into a **method** object.
> 
> Maybe this?
> 
>   With the instance object (if any) and class object available,
>   it's easy to create a method object that wraps the function object.

That's perfect.

But there's also a typo to fix in the Python implementation of the 
Method object: in the call method, it should inject self.im_self as 
first arg, not self.im_func. This had been spotted by someone named John 
Posner, IIRC !-)


> 
> Begging pardon for my presumptuousness,

Begging pardon for my laziness :-/



More information about the Python-list mailing list