7 Nov
2002
7 Nov
'02
1:25 p.m.
- 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 defines a __nonzero__() or __len__() method, and that method returns the integer zero or bool value False. So using a instance as boolean true depends on the implementation of the class... thats why you always need to test for None. You can find more info about this here; http://www.python.org/doc/current/lib/truth.html -- /Magnus