How do these Java concepts translate to Python?

Ray ray_usenet at yahoo.com
Fri Aug 12 10:41:51 EDT 2005


Roy Smith wrote:
> Quick answer; there are none, all attributes are public.
>
> Slightly longer answer; if you name an attribute with two leading
> underscores (i.e. "__myPrivateData"), there is some name mangling that goes
> on which effectively makes the attribute private.  There are ways around
> it, but you have to know what you're doing and deliberately be trying to
> spoof the system (but, then again, exactly the same can be said for C++'s
> private data).

Well yeah... if you really want it, in Java you can do that too via
reflection. Just that I'm not used to it yet so I feel a bit jittery
with so much power on my hands!

> Soapbox answer; private data is, in some ways, a useful tool, but it is not
> part and parcel of object oriented programming.  I've had people (mostly
> C++/Java weenies) that Python is not an OOPL because it does not enforce
> data hiding.  "Feh", I say to them.

Feh... those weenies don't know what they're talkin about.




More information about the Python-list mailing list