[Zope] testing for "REQUEST is not None"
Magnus Heino
magnus.heino@pleon.sigma.se
Thu, 7 Nov 2002 14:25:55 +0100
> - inside the function, REQUEST is either a Request instance (boolean
> true) or 'None' (boolean false), so testing for
> 'if REQUEST is not None:' is equivalent to 'if REQUEST:'
Nope.
A Request instance is not the same thing as boolean True.
Instances of user-defined classes are considered False if the class defin=
es a=20
__nonzero__() or __len__() method, and that method returns the integer ze=
ro=20
or bool value False.
So using a instance as boolean true depends on the implementation of the=20
class... thats why you always need to test for None.
You can find more info about this here;=20
http://www.python.org/doc/current/lib/truth.html
--=20
/Magnus