[Python-Dev] Self in method body (original) (raw)
Filip GruszczyĆski gruszczy at gmail.com
Mon Dec 8 22:55:21 CET 2008
- Previous message: [Python-Dev] Python-3.0, unicode, and os.environ
- Next message: [Python-Dev] Self in method body
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
There is a large discussion on python-list about Guido's article about new self syntax, therefore I would like to use that to raise similar question: self in the body. Some time ago I was coding in Magik language (http://en.wikipedia.org/wiki/Magik_(programming_language), which is dynamically typed and similar to Smalltalk and actually to Python too - although the syntax is far less appalling. As you can see in the examples, defining methods is very similar to what Guido proposed in his blog, though you don't provide the name of the argument, but the name of the class. Then you just precede attributes with a '.', which is 4 letters less than self. And, well, this rocks ;-)
It is really not a problem to type 4 letters (well, six with a coma and a space) in the signature, but it takes a lot of time to type all those selfs inside the function's body. So I was thinking, if this issue could be raised too, when new self syntax is proposed. Simple example looks like this:
class bar:
def bar.foo(): .x = 5
This could really save a lot of code, while attributes are still easily distinguishable.
-- Filip GruszczyĆski
- Previous message: [Python-Dev] Python-3.0, unicode, and os.environ
- Next message: [Python-Dev] Self in method body
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]