python/nondist/peps pep-0008.txt,1.23,1.24
![](https://secure.gravatar.com/avatar/5198081b8a2202570b712777aee311bc.jpg?s=120&d=mm&r=g)
Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5017 Modified Files: pep-0008.txt Log Message: Clarifications resulting from further discussion with Barry Warsaw. Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pep-0008.txt 27 Mar 2004 20:37:02 -0000 1.23 --- pep-0008.txt 30 Mar 2004 01:12:22 -0000 1.24 *************** *** 475,494 **** Method Names and Instance Variables ! The story is largely the same as for functions; in general use lowercase ! with words separated by underscores to improve readability. Do not use ! a leading underscore for methods accessed by other classes or functions ! that are part of the implementation of an object type. ! Use one leading underscore for "internal" methods and instance variables ! when there is no chance of a conflict with subclass or superclass ! attributes or when a subclass might actually need access to them. ! Use two leading underscores (class-private names, enforced by Python ! 1.4) in those cases where it is important that only the current class ! accesses an attribute. Realize that Python contains enough loopholes so ! that an insistent user could gain access nevertheless, e.g. via the ! __dict__ attribute. Generally, double leading underscores should be ! used only to avoid name conflicts with attributes in classes designed to ! be subclassed. Designing for inheritance --- 475,493 ---- Method Names and Instance Variables ! The story is largely the same as with functions: in general, use ! lowercase with words separated by underscores as necessary to improve ! readability. ! Use one leading underscore only for internal methods and instance ! variables which are not intended to be part of the class's public ! interface. Python does not enforce this; it is up to programmers to ! respect the convention. ! Use two leading underscores to denote class-private names. Python ! "mangles" these names with the class name: if class Foo has an ! attribute named __a, it cannot be accessed by Foo.__a. (An insistent ! user could still gain access by calling Foo._Foo__a.) Generally, ! double leading underscores should be used only to avoid name conflicts ! with attributes in classes designed to be subclassed. Designing for inheritance
participants (1)
-
kbk@users.sourceforge.net