Bug or Feature: self.__varname only as self._ClassName__varname

Hans Georg Krauthaeuser hgk at et.uni-magdeburg.de
Wed Jun 16 08:41:10 CEST 2004


Hi all,

I don't know if this is feature. For me it looks like a bug?!

###########################################
import sys

class CTest:
     def __init__(self):
         self.test="Test"
         self._test="_Test"
         self.__test="__Test"

if __name__ == "__main__":
     t = CTest()
     print t.test
     print t._test
     try:
         print t.__test
     except:
         print sys.exc_type
     print t._CTest__test
############################################
The output is:

Test
_Test
exceptions.AttributeError
__Test


python is:
Python 2.3.4 (#2, May 29 2004, 03:31:27)
[GCC 3.3.3 (Debian 20040417)] on linux2

same on windows with python 2.3

Any comments?

Best regards
Hans Georg



More information about the Python-list mailing list