Protecting instance variables

Nikolaus Rath Nikolaus at rath.org
Fri Jul 18 12:03:22 CEST 2008


Hello,

I am really surprised that I am asking this question on the mailing
list, but I really couldn't find it on python.org/doc.

Why is there no proper way to protect an instance variable from access
in derived classes?

I can perfectly understand the philosophy behind not protecting them
from access in external code ("protection by convention"), but isn't
it a major design flaw that when designing a derived class I first
have to study the base classes source code? Otherwise I may always
accidentally overwrite an instance variable used by the base class...


Best,

   -Nikolaus

-- 
 »It is not worth an intelligent man's time to be in the majority.
  By definition, there are already enough people to do that.«
                                                         -J.H. Hardy

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C




More information about the Python-list mailing list