From: avdi@... (Avdi B. Grimm) Date: 2002-09-10T10:10:44+09:00 Subject: Re: Larry Wall's comments on Ruby > Python was always OO insofar as its implementation of OO can be > called OO. Would that this were so. However, it's not; and no amount of claiming that it was will change history. In the words of the Python FAQ: 6.7. Why must 'self' be declared and used explicitly in method definitions and calls? ...When classes were added to Python, this was (again) the simplest way of implementing methods without too many changes to the interpreter. [The FAQ then proceeds to spend a couple paragraphs attempting to rationalize why this is a feature, not a bug] Python's OO is bolted on, and it shows. It's true that it was bolted on at a much younger stage than Perl's, long before it came to massive popularity. But as the Python FAQ admits, the reason you have to hold the compiler's hand in Python by explicitly declaring the 'self' variable is was *not* a conscious design choice, as some have later come to claim. It is that way because that was the easiest way to kludge OO support in, and no one ever got around to fixing it. This also the reason that Pythons types and classes were not unified until very recently, and why old Python code uses the procedural 'String.foo(mystring)' functions rather than the more OO 'mystring.foo()' methods. The strongest argument for this design is that since Python doesn't have variable declarations (like Ruby), you need a way to tell the compiler you are creating an instance variable rather than a local variable. A closely related argument is that it's an aid to the reader to have instance variables clearly marked wherever they are used. Ruby neatly solves this with the '@foo' notation. Python, eschewing "funny characters", could still have solved this by making 'self' a keyword and requiring all uses of instance variables use the 'self.foo' notation. Don't tell any of this to a loyal Python user though, if you value your hide. One of the reasons I prefer both Perl and Ruby over Python for most tasks is just this - the community. Perl users - and Larry himself - are perfectly happy to admit that Perl's OO is a bolted-on hack (albeit a clever one). And Ruby was OO from inception. On the other hand the Python crowd would, in my experience, prefer to explain to you at length why it's your definition of OO that's flawed, rather than the language. ~Avdi