Why less emphasis on private data?

robert no-spam at no-spam-no-spam.invalid
Sun Jan 7 13:41:35 CET 2007


time.swift at gmail.com 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..

What is the use of private declarations, if the names themselves are not verbose about it?

=> You'll always search the class definition/doc to check if the member is below "private" or you wait for compiler errors. If you still want to override, you have to declare 'friends' and all that school boy stuff.

=> Its not useful and efficient for programmers but probably more fulfilled teachers lust itching disciples, when those languages where invented.

Moreover, in those languages there is more or less a clash of namespaces: All globals, module globals, members, local variables and possibly 'with'-variables. This confusion mixed with private declarations will soon provide a situation where one looses overview, what variable exactly was meant.

The syntax in Python with _'s and 'self.' and true modularization and minimal magic namespace behavior, but with explicit self-similiar access to objects, modules, functions and everything is overall most clear und effective. After all I don't know another language which behaves so well in this regard. 

Even Ruby (little positive: it has not even the 'global' variable declaration) is much more ill below the line in that modules,classes, methods/functions.. are not objects but namespaces, messages etc. - thus self-similarity is so broken, that this which will actually limit the power and scalability of this language.


Robert


> It appears to me (perhaps wrongly) that Python prefers to leave class
> data public.  What is the logic behind that choice?
> 
> Thanks any insight.



More information about the Python-list mailing list