[Tutor] pseudo-private but protected?

Alan Gauld alan.gauld at blueyonder.co.uk
Mon Feb 23 17:28:38 EST 2004


> I think I get the pseudo-private name-mangling device.
>
> Are there any conventions or devices for 'pseudo-protected'
attributes
> and methods in Python?

As a matter of interest, why do you think such a thing would be
useful?

> These are accessible by members of the hierarchy, but not outside.

That's one definition of protected, as used in Java and C++.
It's not a universal definition - Delphi for example takes another
approach. The "protected method" style of OO programming is best
used as a form of protection for the programmer when dealing with
statically typed languages with function overloading based on
typed parameters. It basically provides a means of simplifying
the public interface while allowing access to multiple typed
versions of that interface. Since Python does not use that mechanism,
protected methods are somewhat irrelevant.

Which is why I ask why you thought you might want them?

Alan G.




More information about the Tutor mailing list