http://blog.csdn.net/lanphaday/archive/2007/08/09/1734990.aspx
http://hi.baidu.com/zengjianyuan/blog/item/21dbb551650c6713367abe86.html
笔记:
[filwsyl@jianyuan python]$ python
Python 2.6.2 (r262:71600, Aug 21 2009, 12:22:21)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class shit:
... def __private(self):
... print 'hello'
...
>>> a=shit()
>>> a.__private()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: shit instance has no attribute '__private'
>>> dir(shit)
['__doc__', '__module__', '_shit__private']
>>> a._shit__private()
hello
>>>
No comments:
Post a Comment