Python论坛  - 讨论区

标题:Re: Re: [python-chinese]关于 self

2004年03月23日 星期二 10:25

刘鑫 liux at gdcn.com
Tue Mar 23 10:25:03 HKT 2004

poly,您好! 

  准确的说,是当前对象。而且是在这个成员被声明之后的代码才可以访问它。

======== 2004-03-23 09:54:26 您在来信中写道: ========

呵呵,明白了。谢谢各位,如果用了self.xx就能在一个类中任何地方(方法)访问吧?
----- Original Message ----- 
From: 0.706 
To: python-chinese at lists.python.cn 
Sent: Tuesday, March 23, 2004 9:01 AM
Subject: Re: [python-chinese]关于 self


poly,您好! 

  关键在前面的self,这说明了该变量是属于实例的。如果前面没有self,才是局部变量.

======== 2004-03-23 08:56:58 您在来信中写道: ========

我看见书上的代码,比如在__init__中用
self.aa=""
self.bb=""
后,这个aa,bb应该是只属于__init__的局部变量嘛,为什么在其他方法中还可以用self.aa来调用呢,这不是成了全局变量?有点没有搞懂,请指点

= = = = = = = = = = = = = = = = = = = = = = 
        致
礼!

              0.706
              0.706 at 163.com
                 2004-03-23




_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese


= = = = = = = = = = = = = = = = = = = = = = 
        致
礼!

              刘鑫
              liux at gdcn.com
                 2004-03-23
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040323/cc535ce5/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号