Semantics question...

Guido van Rossum guido at python.org
Thu May 18 11:18:15 EDT 2000


Francis Glassborow wrote:
> 
> In article <3921CA22.6458AB08 at webamused.com>, Joshua Macy
> <amused at webamused.com> writes
> >  Essentially, to make instance members visually distinct from method
> >locals.  The other OO languages you're thinking of put an implicit
> >"this." in front of (some) accesses within a method, leading to
> >confusion (at least sometimes) about to whom internal_data belongs.  OO
> >programmers in those languages will then resort to things like naming
> >conventions (e.g. preceding all local names with m_) to help them
> >remember. Python's design disfavors such under the covers "help", so
> >requires that you explicitly pass in a reference to the object as the
> >first parameter (traditionally called "self"), and fully qualify member
> >access.
> 
> Now I could be entirely wrong, but I think the real reason is that
> Python has no concept of declarations and so there is no form of name
> hiding. There is much to be said for Python's identifiers but they do
> not come cost free.  Without declarations the concept of scope and
> lifetime are significantly different.

Excellent observation.  This is indeed the origin of the "self." prefix
requirement.  But I discovered that this is actually an advantage rather
than a problem, and I would never want to go back to Java or C++.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list