Reasoning behind 'self' parameter in classes?

Brett g Porter bgporter at acm.org
Wed Jul 30 20:03:16 CEST 2008


Robert Dailey wrote:

> This is an example of a response I'm looking for:
> "The self parameter is required because the parser is a bit old and 
> needs to know the exact object you're referencing"
> 
> This is _not_ an example of what I'm looking for:
> "Specifying self is a great mysterious thing that we should never 
> question. Do not question the language! The language is mighty! Don't 
> bring C++ to Python!"
> 

Fredrik Lundh has written a  very clear explanation of this at 
http://effbot.org/pyfaq/why-must-self-be-used-explicitly-in-method-definitions-and-calls.htm

(or http://bit.ly/3EUiCf if you don't feel like stitching that URL back 
together...)




More information about the Python-list mailing list