can someone explain?

Mike Meyer mwm at mired.org
Mon Feb 17 17:50:38 EST 2003


Pastula Pawe³ <pawelp at softsystem.pl> writes:

> There is still one thing I'm thinking about.
> Why did Python authors abandoned encapsulation in classes?

The standard line is "Because we're all adults here." The convention
is that names starting with an _ are private, and clients of a class
are expected to not touch those. But if you absolutely need to, you
can - knowing full well that an udpated version of the class may break
your code.

You're right that having the comipiler enforce restrictions makes for
the compiler catching some "bugs", but it also makes it impossible to
do some things without changing the class. Python usually takes the
attitude of making things more flexible.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.




More information about the Python-list mailing list