Explicit Frustration of the Self
Sean Ross
sross at connectmail.carleton.ca
Tue Dec 31 13:47:45 EST 2002
More information about the Python-list mailing list
Tue Dec 31 13:47:45 EST 2002
- Previous message (by thread): Explicit Frustration of the Self
- Next message (by thread): Explicit Frustration of the Self
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Andrew Koenig" <ark at research.att.com> wrote in message news:yu99n0mmw48b.fsf at europa.research.att.com... > > How would you like to be able to write it instead? Show us some > examples. Whatever you come up with, I'll bet it will be possible > to find even greater problems. > Well, this will never happen, because it would break too much code, but I've always been partial to making 'self' a keyword and then defining methods as def self.method(*args): pass Personally, I find this both more explicit and more intuitive than the current form, method(self, *args). More explicit, in that it is fairly obvious that you are defining a method that will be called by self, as opposed to defining a method that will be passed self as an argument, as the current form suggests. Moreover, this new form more closely reflects the usage of your method: inside the class, you call the method by using self.method() outside the class, you call the method with an instance, inst.method() You would not call the method as method(self) or method(inst) but the current form makes it look like this is what should be done. We know better because we've learned the proper usage, still I would suggest that the new form is more intuitive than the current for the simple reason that it uses the same form in its definition as in its usage. As regards making self a keyword... it is highly unlikely to be done - backwards compatability, you know. Still, I would like to see it. The use of self is so ubiquitous in python: You can say, def method(this, *args): pass but few if any do for the simple reason that just about everyone else uses self. In particular, I would like to see the keyword self so that I could write code like this: def self.method(arg=self.data): pass as opposed to def method(self, arg=None): if arg is None: arg = self.data or some such similar meanderings. Anyway, hopes and dreams and hills of beans... You can either make what you want or use what you've got. For the time being I'll use what I've got and be grateful to those who've made most of what I want. Thanks, Sean
- Previous message (by thread): Explicit Frustration of the Self
- Next message (by thread): Explicit Frustration of the Self
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list