Method / Functions - What are the differences?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Mar 3 05:56:03 EST 2010


Eike Welk a écrit :
> John Posner wrote:
>> I've updated the text at this location:
>>
>>  >   http://cl1p.net/bruno_0301.rst/
> 
> I think this is a very useful writeup! 
> 
> It would be perfect with a little bit of introduction that says:
> 1. - What it is: "The rough details of method look-up";
> 2. - which contains some of the questions that that made that authors write 
> the text. This way people with similar questions can find it with Google.
> 

John, do you think you could something with the following ?

"""
"Is it a function ? is it a method ? No, it's... " - or : What's in a 
Python method ?

Python newcomers often have hard time understanding the "magic" behind 
Python's methods - and truth is that Python's object model can be a bit 
peculiar when compared to most mainstream (or not-so-mainstream) OOPLs. 
As a matter of fact, there are quite a few threads on c.l.py with either 
direct or indirect questions about what makes a Python method, and I 
must have explained the whole mechanism at least 3 or 4 times there. The 
following text is an edited version of my last attempt, as edited, 
corrected and published by John Posner, MayHisNameBePraised(tm).

This text isn't meant as a replacement for neither the official 
FineManual(tm)[XXX : relevant link] nor the very excellent - if somehow 
technical - 'Descriptors how-to' [XXX : relevant link]. It's mostly a 
brief but hopefully helpful overview of what exactly is a Python method, 
and how Python magically inserts the 'self' or 'cls' argument to method 
calls.
"""

Feel free to edit / amend / rewrite / trash at will - you're now 
officially in charge of publishing this text !-)




More information about the Python-list mailing list