Why do class methods always need 'self' as the first parameter?

Neil Cerutti neilc at norwich.edu
Wed Aug 31 11:05:41 EDT 2011


On 2011-08-31, T. Goodchild <tgoodchild at gmail.com> wrote:
> I?m new to Python, and I love it.  The philosophy of the
> language (and of the community as a whole) is beautiful to me.
>
> But one of the things that bugs me is the requirement that all
> class methods have 'self' as their first parameter.  On a gut
> level, to me this seems to be at odds with Python?s dedication
> to simplicity.

Think it through carefully, and you'll probably agree with
Python's design. But not necessarily.

In any case, this is a very common complaint, so check out the
Python FAQ.

http://docs.python.org/faq/design.html#why-self

-- 
Neil Cerutti
"A politician is an arse upon which everyone has sat except a man."
  e. e. cummings 



More information about the Python-list mailing list