"Ray" <[EMAIL PROTECTED]> wrote: > I've been learning Python in my sparetime. I'm a Java/C++ programmer by > trade. So I've been reading about Python OO, and I have a few questions > that I haven't found the answers for :) > > 1. Where are the access specifiers? (public, protected, private)
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). 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. -- http://mail.python.org/mailman/listinfo/python-list