Newbie Q: Class Privacy (or lack of)

Ray ray_usenet at yahoo.com
Fri Jul 28 09:48:48 EDT 2006


Ben Sizer wrote:
> Ray wrote:
> But remember, at no point did they think to make that stuff
> deliberately hard so that it would give you safety. It's hard because
> the implementation is relatively complex. The flipside of that is
> writing function objects in C++, which are an ugly hack to get around
> the fact that you can't just assign functions or define them in-place
> in that language. Python makes it trivial by comparison. And as another
> example, if you use the STL in C++ regularly, you will be familiar with
> the hoops you have to jump through in order to use generic functions.
> eg. try to call a polymorphic member function on each pointer in an
> std::map, while passing a fixed parameter to that function... this sort
> of thing is trivial in Python as a side-effect of the fact that the
> attributes are looked up at run-time.

Yeah, I know what you mean. Perhaps that wasn't a good example, but
what I meant was simply that it's different. It doesn't even have to be
complicated like in the C++ case, just different, so say the
interpreter would be able to tell: "oh, this guy wants to rebind the
method", and "oh, that is an error". Right now it can't tell because
both look the same.

I really did like C++ btw. Now I had to force myself really hard just
to get through one chapter off a good book like Effective STL, because
all the time something at the back of my head was telling me like that
that was basically a book about jumping through hoops :)

> 
> -- 
> Ben Sizer




More information about the Python-list mailing list