[ Thomas Ploch <[EMAIL PROTECTED]> ] > sturlamolden schrieb: >> [EMAIL PROTECTED] wrote: >>> Coming from a C++ / C# background, the lack of emphasis on private >>> data seems weird to me. I've often found wrapping private data >>> useful to prevent bugs and enforce error checking.. >>> >>> It appears to me (perhaps wrongly) that Python prefers to leave >>> class >>> data public. What is the logic behind that choice? >> >> The designers of Java, C++, C#, Ada95, Delphi, etc. seem to think >> that if an object's 'internal' variables or states cannot be kept >> private, programmers get an irresistible temptation to mess with them >> in malicious ways. But if you are that stupid, should you be >> programming in any language? The most widely used language is still >> C, and there is no concept of private data in C either, nor is it >> needed. > > There is a kind of this concept in C with 'static' declarations. > >> As mentioned in other replies, it is not rocket science to access a >> class private data. In C++ you can cast to void*, in Java and C# you >> can use reflection. C++ is said to be an "unsafe" language because >> programmers can, using a few tricks, mess with the vtables. But how >> many really do that? > > Exactly, if they were available, a lot more would do that. I think > this is the point. Programmers who can do that normally are sensible > towards that people who have designed this or that knew what they were > doing. But there are enough people that don't have a clue and _will_ > fiddle around and then flame all kind of mailing lists with requests > for help cause they did it wrong.
Those people deserve to fail for being just extraordinary stupid... -- Freedom is always the freedom of dissenters. (Rosa Luxemburg) -- http://mail.python.org/mailman/listinfo/python-list