看看这段文章的输出

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

看看这段文章的输出

侯华隆
刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 看看这段文章的输出

weizi-2
Mail
python-chinese,你好
运行了一下。输出:
 
A.__private()
B.public()
 
 
2007-08-17
----- Original Message -----
Sent: 2007-08-17, 15:49:42
Subject: [python-chinese] 看看这段文章的输出

刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 看看这段文章的输出

赵威
In reply to this post by 侯华隆
侯华隆,您好!
 
 因为python的class里的__开头的被改名了。
看看这个:
 
class A(object):
       def __init__(self):
              self._B__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
 
======== 2007-08-17 15:49:42 您在来信中写道: ========
 
刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

= = = = = = = = = = = = = = = = = = = = = =

        致
礼!

 
              赵威
              [hidden email]
               2007-08-17
 

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Rs: Re: 看看这段文章的输出

weizi-2
In reply to this post by 侯华隆
Mail
python-chinese,你好
运行了一下。输出:
 
A.__private()
B.public()
 
 
2007-08-17
----- Original Message -----
Sent: 2007-08-17, 15:49:42
Subject: [python-chinese] 看看这段文章的输出

刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: Rs: Re: 看看这段文章的输出

dezhong liu
A.__private()
B.public()

在07-9-5,nmweizi <[hidden email]> 写道:
python-chinese,你好
运行了一下。输出:
 
A.__private()
B.public()
 
 
nmweizi,[hidden email]
2007-08-17
----- Original Message -----
Sent: 2007-08-17, 15:49:42
Subject: [python-chinese] 看看这段文章的输出

刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to   [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: Rs: Re: 看看这段文章的输出

Cyril.Liu
OOP考题中经常出现的题目

On 9/5/07, dezhong liu <[hidden email]> wrote:
A.__private()
B.public()

在07-9-5,nmweizi <[hidden email]> 写道:
python-chinese,你好
运行了一下。输出:
 
A.__private()
B.public()
 
 
nmweizi,[hidden email]
2007-08-17
----- Original Message -----
Sent: 2007-08-17, 15:49:42
Subject: [python-chinese] 看看这段文章的输出

刚看了一篇文章
class A(object):
       def __init__(self):
              self.__private()
              self.public()
       def __private(self):
              print 'A.__private()'
       def public(self):
              print 'A.public()'
class B(A):
       def __private(self):
              print 'B.__private()'
       def public(self):
              print 'B.public()'
b = B()
猜猜输出什么?

侯华隆
2007-08-17

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to   [hidden email]
Detail Info: <a href="http://python.cn/mailman/listinfo/python-chinese" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to   [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese