Python论坛  - 讨论区

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

2004年03月24日 星期三 20:10

Nature.Liu Nature.Liu at advantech.com.cn
Wed Mar 24 20:10:07 HKT 2004

 Dear Zoom.Quiet:
	=D0=BB=D0=BB
	self.db=3DDB(storage)=CA=C7=BF=C9=D0=D0=B5=C4=A3=AC
	=B5=ABself.db.close=BA=C3=CF=F1=BB=B9=CA=C7=CE=DE=D0=A7

-----=D4=AD=CA=BC=E0]=BC=FE-----
=BC=C4=BC=FE=D5=DF: python-chinese-bounces at lists.python.cn =
[mailto:python-chinese-bounces at lists.python.cn] =B4=FA=C0=ED Zoom.Quiet
=BC=C4=BC=FE=C8=D5=C6=DA: 2004=C4=EA3=D4=C224=C8=D5 19:52
=CA=D5=BC=FE=D5=DF: python-chinese at lists.python.cn
=D6=F7=D6=BC: Re: [python-chinese] =
=B9=D8=D3=DA=B1=E4=C1=BF=B5=C4=D7=F7=D3=C3=D3=F2=B5=C4=CE=CA=CC=E2

Hello Nature.Liu,

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

self.db.close()


=CA=C7=D2=B2=BA=F5=A3=BF
=3D=3D=3D [ 19:29 ; 04-03-24 ] you wrote:

=20
NL> =
=C7=EB=CE=CA=A3=BA=CE=D2=D3=C3wxpython=B1=E0=B5=C4gui=A3=AC=B5=B1=B4=B0=CC=
=E5=D3=D0=D0=A7=CA=B1=B4=F2=BF=AA=A3=A8=D0=C2=BD=A8=A3=A9=D2=BB=B8=F6zodb=
=BF=E2=A3=AC=CE=D2=CF=EB=D4=DA=B9=D8=B1=D5=B4=B0=CC=E5=CA=B1=B9=D8=B1=D5=CA=
=FD=BE=DD=BF=E2=A3=AC
NL> =C8=E7=A3=BAdef OnWxframe1Activate(self, event):
NL>         storage =3D FileStorage.FileStorage('record.fs')=20
NL>         db =3D DB(storage)
NL>         conn =3D db.open()
NL>         dbroot =3D conn.root()
NL>         dbname =3D 'recordlist'
NL>         dbroot[dbname]=3DOOBTree()
NL>         list =3D dbroot[dbname]
NL>         class record(Persistent):
=20
=20
NL>         def OnWxframe1Close(self, event):
NL>             db.close()
NL>             self.Close()
NL>             self.Destroy()
       =20
NL> =
=CE=AA=BA=CE=CB=B5db=D5=E2=B8=F6=B1=E4=C1=BF=B2=BB=CA=C7=C8=AB=BE=D6=B1=E4=
=C1=BF=A3=AC=C4=C7=CE=D2=D3=D6=C8=E7=BA=CE=B5=F7=D3=C3db=D5=E2=B8=F6=B1=E4=
=C1=BF=C4=D8

NL> ________________________________

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


=3D=3D=3D =3D=3D=3D =3D=3D=3D =3D=3D=3D =3D=3D=3D =3D=3D=3D =3D=3D=3D =
=3D=3D=3D =3D=3D=3D =3D=3D=3D=20

--
Best regards,
 Zoom.Quiet                           =20

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

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



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

2004年03月25日 星期四 09:21

poly gentooo at 163.com
Thu Mar 25 09:21:56 HKT 2004

其实用self.db就行了,在类里任何地方都可以引用
----- Original Message ----- 
From: "Levin" <zsdjw at 21cn.com>
To: <python-chinese at lists.python.cn>
Sent: Thursday, March 25, 2004 10:34 AM
Subject: Re: 回覆: [python-chinese] 关于变量的作用域的问题


> 要用全局变量,最好使用前先声明一下
> 
>> 
> global db
> 
> 加入方法首部
> 
> Nature.Liu wrote:
> 
> > Dear Zoom.Quiet:
> > 谢谢
> > self.db=DB(storage)是可行的,
> > 但self.db.close好像还是无效
> >
> >  
> >
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese

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

2004年03月25日 星期四 10:34

Levin zsdjw at 21cn.com
Thu Mar 25 10:34:55 HKT 2004

要用全局变量,最好使用前先声明一下

将

global db

加入方法首部

Nature.Liu wrote:

> Dear Zoom.Quiet:
>	谢谢
>	self.db=DB(storage)是可行的,
>	但self.db.close好像还是无效
>
>  
>



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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号