Will python never intend to support private, protected and public?
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Fri Sep 30 06:50:10 EDT 2005
On Fri, 30 Sep 2005 06:31:44 +0200, Fredrik Lundh wrote:
> en.karpachov at ospaz.ru wrote:
>
>> Looks like you must know every one of the base classes of the NotSoSecret,
>> whether there is some base class named Secret? And, if so, you must also
>> know these classes _implementation_
>
> that information isn't hidden, so there's nothing "you must know". finding out
> is a matter of writing a very small program, or tinkering at the interactive prompt
> for a couple of seconds.
Which of course is only possible because Python does not hide information,
it uses semi-private attributes rather than secret private ones, and
allows close to full introspection.
Still, en.karpachov at ospaz.ru's point that you must know the base classes
is correct. It is *easy* to find them out (NotSoSecret.__bases__ should do
it), but if you don't you are taking a chance that your class name doesn't
clash with one of the bases.
In other words, this is a Gotcha, not a world-shattering disaster.
--
Steven.
More information about the Python-list
mailing list