Why does python not have a mechanism for data hiding?
ncoghlan at gmail.com
Wed Jun 4 13:14:04 CEST 2008
On May 26, 2:49 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
> I am also bothered a bit by the seeming inconsistency of the rules for
> the single underscore. When used at file scope, they make the variable
> or function invisible outside the module, but when used at class
> scope, the "underscored" variables or functions are still fully
> visible. For those who claim that the client should be left to decide
> what to use, why is the client prohibited from using underscored
> variables at file scope?
They aren't - the only thing that won't see the underscore prefixed
names is "from x import *". If you do "import x" instead, all the
underscored names will be accessible as attributes of the module.
More information about the Python-list