Python programmers prefer to use name convention to make method of class "looks" private.
Usually they use of '_' before the private method or private attribute name.

This private method like the one you mentioned def _abc is not intentionaly used outside the class other then it is used among other class methods privately.

Example:
class A:
    def __init__(self, myvar):
        self._myvar = myvar
    def _makedouble(self):
        '''this method is private'''
        self._myvar = self._myvar * 2
   
    def printvarADouble(self):
        self._makedouble()
        print self._myvar

def main():
    o = A(2)
    o.printvarADouble() # 4


You may use def abc instead of def _abc, again it is only a convention.


Hope this helps,
pujo





On 4/13/06, linda.s < [EMAIL PROTECTED]> wrote:
I got a sample code and found some
function definition looks like def _abc
There is one underscore before the function name "abc",
what does it mean?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to