Explicit Frustration of the Self

Andres Rosado arosado at softhome.net
Thu Jan 9 01:40:11 CET 2003

On 04:56 AM 1/4/2003 -0500, the keyboard of python-list-request at python.org 
>Another thought: how OO is Python?  It allows me to create Objects, I
>guess.  But do these objects really have methods?  I don't think so.
>Not with the way self acts now.  Right now, you are effectively,
>creating functions and then calling them with the first argument
>outside of the parenthesis, and to the left of the function, and a
> >>> class Object:
>...     name = "Bob"
> >>> def foo(self, argument):
>...     print argument + self.name
> >>> o = Object()
> >>> foo(o, "Hello ")
>Hello Bob
>Which is pretty much the same as:
> >>> class Object:
>...     name = "Bob"
>...     def foo(self, argument):
>...             print argument + self.name
> >>> o = Object()
> >>> o.foo("Hello ")
>Hello Bob
>I really don't see much of a difference between foo(o, "Hello ") and
>o.foo("Hello ").  It must be easy from the point of view of the python
>programming, all you bassically do is mangle it to "Object_foo(self,
>blah)", and pre-process all "object.foo(" to "object_foo(".  Seems to
>So the only real difference is that Object.foo won't conflict with
>OtherObject.foo.  But that doesn't seem like the basis of OO.
>In the end OOP is all about the revolution, not of efficiency or
>computational effectiveness, but of how we can understand the
>structure of the world that we create, its objects, its functions.
>The idea of the explicit self retards this understanding, I believe,
>and forces us to view python objects as code, not objects of a

That's actually how C++ handles classes too. That's why they have the 
implicit "this" pointer. When classes are created, IIRC, only the data is 
individual[1]. All functions are shared, and the first parameter of EVERY 
function in the class is <drum roll>: '*this'[2]. So we end up in the same 
direction for eficiency reasons.

[1] Static data is shared, of course.
[2] Static functions don't receive the this pointer.

Andres Rosado
Email: andresr at despammed.com
ICQ: 66750646
Homepage: http://andres980.tripod.com/

Most people have two reasons for doing anything --
a good reason, and the real reason.

More information about the Python-list mailing list