Popular style document?

Björn Lindberg d95-bli.no at spam.nada.kth.se
Sat Mar 23 08:15:40 EST 2002


Michael Chermside wrote:

> Advantages of "Automatic" access to instance variables:
>    * Less typing.
>    * Somewhat more convenient to use objects (because you don't have to
>      type "self." in front of instance variable accesses. Mostly about
>      there being less typing.)

But this is not the same question as the one i discussed. The fact that
the variable "i" in a class in C++ hides a variable "i" in an outer
scope is just that; scope rules. It works the same way as when "i" in a
function hides a global variable "i". This is because of scope rules and
doesn't have anything directly to do with the explicit reference to
"self".

>    * Functions and Methods have a VERY simple relationship... methods
>      are just functions that take an instance as their first parameter.
>      This allows you to do things like "myObject.getFoo = myGetFooFunc",
>      to create a new method.

This is what I was wondering about. I think it looks interesting, and as
you say it couldn't reasonably be done unless "self" is explicit.


Björn



More information about the Python-list mailing list