Why self?

Brian Quinlan brian at sweetapp.com
Mon Jul 8 15:27:50 EDT 2002


Robb wrote: 
> I don't think so:  As I understand it, the double underscores are
> necessary in order to for the class to function correctly if
subclassed.
>   Without them, a subclass could inadvertently use/misuse/overwrite
them.

Two leading underscores make the instance variable private. I doubt that
is required in the example that you gave. Actually, private instance
variables are uncommon in general.

> These requirements remind me of C++ or Perl, where in order to do the
> correct thing, you have to go through extra work.  Or, conversely, the
> language encourages you to do the wrong thing.

Python forces you to be explicit. That way we will know what you are
doing, right or wrong.

Cheers,
Brian






More information about the Python-list mailing list