Why less emphasis on private data?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Jan 7 08:20:35 EST 2007


Paul Rubin:
> Python certainly makes you spend more of your attention worrying
> about possible attribute name collisions between classes and their
> superclasses. And Python's name mangling scheme is leaky and
> bug-prone if you ever re-use class names.

> Trouble with this is you can have two classes with the same name,
> perhaps because they were defined in different modules, and then the
> name mangling fails to tell them apart.

Without changing Python syntax at all I think this situation may be
improved. Instead of Python applying name mangling to names with __
before them, it can manage them as private, a higher level kind of
management. And then if it's useful a new built-in function may be
invented to access such private attributes anyway. I think this may
solve your problem. (This is for Py3.0). Maybe a metaclass can be
invented to simulate such behavior to test and try it before modifying
the language itself.

Bye,
bearophile




More information about the Python-list mailing list