saying "if REQUEST is not None" is a much more explicit way of saying "this condition fails because REQUEST really was never passed in". since "None" is the default argument for REQUEST you know for a fact that REQUEST was never passed into the function. it is probably true that any other "non-truth" value should make the condition fail, but some people might prefer to have it not fail and throw errors instead to find out that somehow garbage got passed in as the REQUEST argument. jens On Thursday, Nov 7, 2002, at 06:25 US/Eastern, Willem Broekema wrote:
Geir Bækholt wrote:
if the method was called directly from somewhere , not through the web..
- so that , if you for instance are adding objects programmatically, will not be redirected to manage_main...
Also then, the absense of REQUEST can be tested with just 'if REQUEST'?!
Obviously I'm still not making clear what I want to know:
- 'None' compares to a boolean false
- 'def something(self, REQUEST=None):' gives REQUEST the value None, if it is omitted
- 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:'
As 'if REQUEST' is shorter than '.. is not None', why not use it instead?
Like this:
def something(self, REQUEST=None): # do actions if REQUEST: # redirect to ...
It's equivalent to testing for an empty string: why test for the empty string like this: if s != ''
when you know s is a string, so you can just do: if s:
- Willem
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )