美文网首页
name mangling

name mangling

作者: shuff1e | 来源:发表于2018-03-17 14:08 被阅读4次
    [root@shuffle-dev py_test]$ vim sf_namemangling.py 
     17 class C(A):
     18     def __init__(self):
     19         self.__private()
     20         self.public()
     21     @classmethod
     22     def __private(cls):
     23         print 'C.private'
     24     @staticmethod
     25     def public():
     26         print 'public'
     27 
     28 print '---create b---'
     29 b=B()
     30 print '---create c---'
     31 c=C()
     32 print '---method of class C---'
     33 C._C__private()                                                                                          
     34 C.public()
    
    [root@shuffle-dev py_test]$ ./sf_namemangling.py 
    ---create b---
    A.private()
    B.public
    ---create c---
    C.private
    public
    ---method of class C---
    C.private
    public
    

    相关文章

      网友评论

          本文标题:name mangling

          本文链接:https://www.haomeiwen.com/subject/gfljqftx.html