Jeremy Hylton wrote: > On 12/12/05, Scott David Daniels <[EMAIL PROTECTED]> wrote: >> Perhaps "The __ name convention is designed for 'mixins'; as a means of >> enforcing "private" it is both ineffective and annoying. For example, >> distutils.msvccompiler uses a bunch of instance variables which would I >> would like to access in a subclass, but are "unavailable" because the >> author could not imagine why I would need them. > > These are really separate issues, right? The effect of __ names is to > make a variable private to a class, because it's a right pain to > access it from any other class. If you design a class for inheritance > and use __ names, you're deciding to keep the details of those names > private. For 'mixins' (or other multi-inheritance schemes) the renaming serves a useful (and necessary) function -- collision avoidance.
In a hierarchy designed for inheritance, I suspect fewer problems than I see in the cited code. For code built with no thought of inheritance, it will be easier to (re) use parts if non-'__' names are used. Code built for inheritance is not responsible for the correctness of subclasses; I suspect many '__' names are used in a mistaken attempt to prevent subclasses from making mistakes, rather than attempting to ease their use. --Scott David Daniels [EMAIL PROTECTED] _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com