Python论坛  - 讨论区

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

2004年03月23日 星期二 09:54

poly cdslacker at 163.com
Tue Mar 23 09:54:26 HKT 2004

呵呵,明白了。谢谢各位,如果用了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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040323/e124a710/attachment.htm

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

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

fengjun fengjun at jimagame.com
Tue Mar 23 10:10:55 HKT 2004

一般所有用到的实例变量都在__init__中初始化的。
没左先右当然不行。
  ----- Original Message ----- 
  From: poly 
  To: python-chinese at lists.python.cn 
  Sent: Tuesday, March 23, 2004 9:54 AM
  Subject: Re: [python-chinese]关于 self


  呵呵,明白了。谢谢各位,如果用了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



------------------------------------------------------------------------------


  _______________________________________________
  python-chinese list
  python-chinese at lists.python.cn
  http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040323/76ade709/attachment.html

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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号