[Zope] A quick zope/python question

Jonathan dev101 at magma.ca
Tue May 9 11:32:31 EDT 2006


Thanks to everyone for setting me straight!

I have been (erroneously!) assuming that any defined object would evaluate 
to 'true'.

Thanks again.

Jonathan

----- Original Message ----- 
From: "Jens Vagelpohl" <jens at dataflake.org>
To: "[Zope] Mailing List" <zope at zope.org>
Sent: Tuesday, May 09, 2006 11:25 AM
Subject: Re: [Zope] A quick zope/python question


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> On 9 May 2006, at 16:18, Jonathan wrote:
>> gc= <TransientObjectContainer at GarbageCollector>
>> GarbageCollector exists
>>
>>
>> I think I am misunderstanding something basic about python/zope  here. 
>> Why does a TOC object evaluate to false?
>
> I think the basic misunderstanding is about what happens if you say...
>
> if FOO: ...
>
> Python will try to evaluate using steps such as looking for methods  like 
> __nonzero__, __len__, etc, and you're not aware what these may  evaluate 
> to given your object. A Folder, for example, evaluates to  False when it 
> is empty.
>
> You should use a different test to determine if that item exists.
>
> jens
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (Darwin)
>
> iD8DBQFEYLRlRAx5nvEhZLIRAmSWAKCxP+IjWYHEC/J1E8zDvq0R2OUB1wCePA74
> Fm8Oc74d3dn915gDefbR1Yo=
> =FOpK
> -----END PGP SIGNATURE-----
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
> 



More information about the Zope mailing list