[Zope] Python Scripts

Casey Duncan cduncan@kaivo.com
Tue, 29 May 2001 15:15:45 -0600


> ----- Original Message -----
> From: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be>
> To: <zope@zope.org>
> Sent: Monday, May 28, 2001 11:38 AM
> Subject: [Zope] Python Scripts
> 
> > Hi,
> >
> > How can we in the python script check if the a certain variable exists in
> > the namespace?
> >
> > ie. We can get the value of a variable by using context.myvar or
> > context['myvar'], but both will return an error when the myvar doesn't
> > exists. Now, how can you check if it exists?
> >
> > I tried several things, like context.hasattr('myvar') or
> > context.has_key('myvar') , _hasattr(), _.hasattr() ... etc, but none seem
> to
> > work. Can somebody tell me if it even is possible? Thanks.
> >
> > Tom.
> >
> >

perhaps try:

hasattr(context, 'myvar')
_.has_key('my_var')

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>