Why self?

Brian Quinlan brian at sweetapp.com
Mon Jul 8 17:22:10 EDT 2002


Louis M. Pecora wrote:
> > If the explicit self argument were removed, what would you add to
the
> > language to differentiate between local and instance variables?
> >
> 
> 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.

This would be ugly and slow. The slowness would come from the fact that
locally scoped variables could not be identified during compilation.

Cheers,
Brian






More information about the Python-list mailing list