Why self?

Robb Shecter rs at onsitetech.com
Mon Jul 8 17:42:28 EDT 2002


Louis M. Pecora wrote:
> Here's a stab.  
> 
> (1) All self variables have to be initialized in __init__.  That's just
> good practice anyway.  They are labeled with self in __init__ otherwise
> they are local.  
> 
> (2) There can be no name conflicts between local and self variables. 
> Also good practice within an object.
> 

Good ideas.  Or just do nothing: make self optional as in Java, and the 
  innermost scope is searched first if no self is given.  I've done 
years of Java programming, and have never had issues with instance vs. 
local variables.  It just really doesn't happen in practice because of 
the differences in naming and usage of variables.

How does Ruby handle this?

I think that any of these ideas are good.

Robb




More information about the Python-list mailing list