[Twisted-Python] Re: [Twisted-commits] CVS: Twisted/twisted/protocols basic.py,1.13,1.14
Itamar Shtull-Trauring
lists at itamarst.org
Mon Oct 29 08:16:19 MST 2001
Itamar Shtull-Trauring wrote:
> Modified Files:
> basic.py
> Log Message:
> I was overwriting self.mode by mistake, so I made it private
>
May I add something to the coding standard regarding this?
Index: doc/CodingStandard.html
===================================================================
RCS file: /cvs/Twisted/doc/CodingStandard.html,v
retrieving revision 1.5
diff -c -r1.5 CodingStandard.html
*** doc/CodingStandard.html 2001/10/26 16:33:19 1.5
--- doc/CodingStandard.html 2001/10/29 15:13:53
***************
*** 219,224 ****
--- 219,239 ----
function, class, method, or module, make sure that it won't instantly
break other code.
</p>
+ <p>
+ If your class has attributes that are intended to be private and
+ implementation specific (e.g. the current state of a state-machine),
+ prefix your attribute with __. This will make sure that they don't
+ interfere with subclasses' attributes by mistake. For example:
+ <pre>
+ class Foo:
+
+ __state = 1
+
+ def doSomething(self):
+ # ...
+ self.__state = 2
+ </pre>
+ </p>
<hr>
<address><a href="mailto:glyph at helix.twistedmatrix.com">Glyph
Lefkowitz</a></address>
<!-- Created: Thu Apr 26 07:53:26 CDT 2001 -->
More information about the Twisted-Python
mailing list