Python论坛  - 讨论区

标题:RE: [python-chinese] hello me! __main__ 和self是何东东

2005年07月01日 星期五 08:52

jam.zheng jam.zheng at achievo.com
Fri Jul 1 08:52:53 HKT 2005

谢谢大侠指点:
    可是那个self我还是一头雾水,难道是c++里面的this指针吗?

-----Original Message-----
From: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn]On Behalf Of limodou
Sent: Thursday, June 30, 2005 7:05 PM
To: python-chinese at lists.python.cn
Subject: Re: [python-chinese] hello me! __main__ 和self是何东东


看我那个回复就行了。

2005/6/30, ella wang <ella at exoweb.net>:
> self 可以这么用
> class MyClass(FatherClass):
>         def aa(self):
>                 ***
>                 bb_attr = ***
>                 self.bb(bb_attr)
>                 ***
>         def bb(self, attr):
>                 ***
>
> __name__ 是模块中定义的变量,它定义该模块的名字.
> if __name__ == '__main__':
>         说明,你希望将给定的模块作为脚本运行
>
> 关于这点,我还不太明白,希望高手解释~
>
>
> On Thu, 2005-06-30 at 11:07 +0800, jam.zheng wrote:
> > 各位大侠:
> >     __main__ -- Top-level script environment
> > This module represents the (otherwise anonymous) scope in which the
> > interpreter's main program executes -- commands read either from
standard
> > input, from a script file, or from an interactive prompt. It is this
> > environment in which the idiomatic ``conditional script'' stanza causes
a
> > script to run:
> > if __name__ == "__main__":
> >     main()
> >
> > 能帮我解释一下吗?
> >
> > 还有那个很多源码上用的 self 是什么东东
> >
> > def __init__ (self, receiver, address):
> >         asynchat.async_chat.__init__ (self)
> >         self.receiver = receiver
> >         self.set_terminator (None)
> >         self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
> >         self.buffer = ''
> >         self.set_terminator ('\n')
> >         self.connect (address)
> >
> > _______________________________________________
> > 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
>


--
I like python!
My Donews Blog: http://www.donews.net/limodou
New Google Maillist: http://groups-beta.google.com/group/python-cn


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

2005年07月01日 星期五 10:22

limodou limodou at gmail.com
Fri Jul 1 10:22:06 HKT 2005

self用来表示某个对象的方法
所绑定的对象。因为类只是一个模板,一个类可以创建很多的实例。那么当你调用某个实例的方法时如何知道到底是哪一个对象呢?使用self来判断。就和this的功能是一样的,不过它是一个对象,不是一个指针。

在 05-7-1,jam.zheng<jam.zheng at achievo.com> 写道:
> 谢谢大侠指点:
>     可是那个self我还是一头雾水,难道是c++里面的this指针吗?
> 
> -----Original Message-----
> From: python-chinese-bounces at lists.python.cn
> [mailto:python-chinese-bounces at lists.python.cn]On Behalf Of limodou
> Sent: Thursday, June 30, 2005 7:05 PM
> To: python-chinese at lists.python.cn
> Subject: Re: [python-chinese] hello me! __main__ 和self是何东东
> 
> 看我那个回复就行了。
> 
> 2005/6/30, ella wang <ella at exoweb.net>:
> > self 可以这么用
> > class MyClass(FatherClass):
> >         def aa(self):
> >                 ***
> >                 bb_attr = ***
> >                 self.bb(bb_attr)
> >                 ***
> >         def bb(self, attr):
> >                 ***
> >
> > __name__ 是模块中定义的变量,它定义该模块的名字.
> > if __name__ == '__main__':
> >         说明,你希望将给定的模块作为脚本运行
> >
> > 关于这点,我还不太明白,希望高手解释~
> >
> >
> > On Thu, 2005-06-30 at 11:07 +0800, jam.zheng wrote:
> > > 各位大侠:
> > >     __main__ -- Top-level script environment
> > > This module represents the (otherwise anonymous) scope in which the
> > > interpreter's main program executes -- commands read either from
> standard
> > > input, from a script file, or from an interactive prompt. It is this
> > > environment in which the idiomatic ``conditional script'' stanza causes
> a
> > > script to run:
> > > if __name__ == "__main__":
> > >     main()
> > >
> > > 能帮我解释一下吗?
> > >
> > > 还有那个很多源码上用的 self 是什么东东
> > >
> > > def __init__ (self, receiver, address):
> > >         asynchat.async_chat.__init__ (self)
> > >         self.receiver = receiver
> > >         self.set_terminator (None)
> > >         self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
> > >         self.buffer = ''
> > >         self.set_terminator ('\n')
> > >         self.connect (address)
> > >
> > > _______________________________________________
> > > 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
> >
> 
> --
> I like python!
> My Donews Blog: http://www.donews.net/limodou
> New Google Maillist: http://groups-beta.google.com/group/python-cn
> 
> 


-- 
I like python! 
My Donews Blog: http://www.donews.net/limodou
New Google Maillist: http://groups-beta.google.com/group/python-cn

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

2005年07月01日 星期五 10:27

albertlee hanzhupeng at 163.com
Fri Jul 1 10:27:35 HKT 2005

limodou,你好
    
    我有两台服务器,要把其中一台上运行的mysql中的表结构复制到另一台mysql 

albertlee,hanzhupeng at 163.com
2005-7-1 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050701/e08287d1/attachment.html

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

2005年07月01日 星期五 10:33

albertlee hanzhupeng at 163.com
Fri Jul 1 10:33:46 HKT 2005

albertlee,你好

奇怪,刚才的信没发完整

我刚刚在 google上搜到一篇 limodou兄写的文章,

albertlee,hanzhupeng at 163.com
2005-7-1 
----- 收到以下来信内容 ----- 
发件人: albertlee 
收件人: limodou,python-chinese 
时  间: 2005-07-01, 10:27:35
主  题: [python-chinese] Re: Mysql 数据库表结构的导出问题


limodou,你好
    
    我有两台服务器,要把其中一台上运行的mysql中的表结构复制到另一台mysql 

albertlee,hanzhupeng at 163.com
2005-7-1 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050701/c125cb37/attachment.htm

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

2005年07月01日 星期五 10:34

Neo Chan (netkiller) neo.chen at achievo.com
Fri Jul 1 10:34:45 HKT 2005

Skipped content of type multipart/mixed-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3066 bytes
Desc: not available
Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20050701/241f66af/smime.bin

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

2005年07月01日 星期五 10:36

nEO gentoo.cn at gmail.com
Fri Jul 1 10:36:43 HKT 2005

dump出来就好

在05-7-1,albertlee <hanzhupeng at 163.com> 写道:
> 
> limodou,你好
>   我有两台服务器,要把其中一台上运行的mysql中的表结构复制到另一台mysql 
>  <%--AID_FROMNAME_BEGIN--%>albertlee<%--AID_FROMNAME_END--%>,
> <%--AID_FROMADDRESS_BEGIN--%>hanzhupeng at 163.com<%--AID_FROMADDRESS_END--%><%3C%25--AID_FROMADDRESS_BEGIN--%25%3Ehanzhupeng at 163.com%3C%25--AID_FROMADDRESS_END--%25%3E>
> 2005-7-1 
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> 


-- 
I'm the one, powered by nEO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050701/dc83aa3a/attachment.html

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号