Getting rid of "self."
roy at panix.com
Fri Jan 7 12:12:15 EST 2005
In article <10ttf1slqmefi28 at news.supernews.com>,
John Roth <newsgroups at jhrothjr.com> wrote:
>"Roy Smith" <roy at panix.com> wrote in message
>news:crmdqk$jo6$1 at panix2.panix.com...
>> Simon Brunning <simon at brunningonline.net> wrote:
>>>On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <luismgz at gmail.com> wrote:
>>>> The word "self" is not mandatory. You can type anything you want
>>>> instead of self, as long as you supply a keyword in its place (it can
>>>> be "self", "s" or whatever you want).
>>>You *can*, yes, but please don't, not if there's any chance that
>>>anyone other than you are going to have to look at your code.
>>>'self.whatever' is clearly an instance attribute. 's.whatever' isn't
>>>clearly anything - the reader will have to go off and work out what
>>>the 's' object is.
>> If there is one coding convention which is constant through the Python
>> world, it's that the first argument to a class method is named
>> "self". Using anything else, while legal, is just being different for
>> the sake of being different.
>Didn't you mean instance method? Class methods are a different
>beast, and the few examples I've seen seem to use the word "klas".
Sorry, yes. My bad.
I used to work with a C++ guy who always used "class" when he should
have used "instance". It drove me crazy. :-)
More information about the Python-list