Python论坛  - 讨论区

标题:[python-chinese] 关于变量的作用域的问题

2004年03月24日 星期三 19:29

Nature.Liu Nature.Liu at advantech.com.cn
Wed Mar 24 19:29:15 HKT 2004

 
请问:我用wxpython编的gui,当窗体有效时打开(新建)一个zodb库,我想在关闭窗体时关闭数据库,
如:def OnWxframe1Activate(self, event):
        storage = FileStorage.FileStorage('record.fs') 
        db = DB(storage)
        conn = db.open()
        dbroot = conn.root()
        dbname = 'recordlist'
        dbroot[dbname]=OOBTree()
        list = dbroot[dbname]
        class record(Persistent):
 
 
        def OnWxframe1Close(self, event):
            db.close()
            self.Close()
            self.Destroy()
        
为何说db这个变量不是全局变量,那我又如何调用db这个变量呢

________________________________

Upgrade Your Email - Click here! <http://promos.hotbar.com/promos/promodll.dll?RunPromo&El;=hotbar%5felement%3bst%3b&SG;=&RAND;=56517&partner;=hotbar>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040324/698b1f94/attachment.htm

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

2004年03月24日 星期三 19:51

Zoom.Quiet zoomq at infopro.cn
Wed Mar 24 19:51:56 HKT 2004

Hello Nature.Liu,

self.db = DB(storage)
....

self.db.close()


是也乎?
=== [ 19:29 ; 04-03-24 ] you wrote:

 
NL> 请问:我用wxpython编的gui,当窗体有效时打开(新建)一个zodb库,我想在关闭窗体时关闭数据库,
NL> 如:def OnWxframe1Activate(self, event):
NL>         storage = FileStorage.FileStorage('record.fs') 
NL>         db = DB(storage)
NL>         conn = db.open()
NL>         dbroot = conn.root()
NL>         dbname = 'recordlist'
NL>         dbroot[dbname]=OOBTree()
NL>         list = dbroot[dbname]
NL>         class record(Persistent):
 
 
NL>         def OnWxframe1Close(self, event):
NL>             db.close()
NL>             self.Close()
NL>             self.Destroy()
        
NL> 为何说db这个变量不是全局变量,那我又如何调用db这个变量呢

NL> ________________________________

NL> Upgrade Your Email - Click here!
NL> <http://promos.hotbar.com/promos/promodll.dll?RunPromo&El;=hotbar%5felement%3bst%3b&SG;=&RAND;=56517&partner;=hotbar>


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

-- 
Best regards,
 Zoom.Quiet                            

 /=======================================\
]Time is unimportant, only life important![
 \=======================================/



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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号