Another Language Change for Debate

brueckd at tbye.com brueckd at tbye.com
Fri Jan 11 15:05:28 EST 2002


On Fri, 11 Jan 2002, Michael Chermside wrote:

> class MyClass(OtherClass):
>     def addItems( newItems ):
>        self.items += newItems
>
> Of course what I've forgotten to do here is to declare 'self' as the
> first parameter to addItems(). The reason I forgot is that when I CALL
> the method it looks like this:
>       myObj.addItems( userItems )
[snip]
> So here's my idea. Allow the following syntax:
>
> class MyClass(OtherClass):
>     def self.addItems( newItems ):
>        self.items += newItems
[snip]

I sometimes make this mistake, but it gets caught the very first time the
function is run, so it causes no real pain. If it happens a lot, use your
editor's macro capabilities to generate skeleton method code for you.

-Dave





More information about the Python-list mailing list