Lennart Regebro wrote at 2003-3-7 15:57 +0100:
 > 1. Python is kept as is.
 > 2. To support one-line if-else in attributes in ZPT, the python 
 > expressions used in ZPT imports an extra method. This method can be 
 > called whetever people want it toi be called, but for claritys sake lets 
 > call it 'if_else'
 >    if_else(expression, true_result, false_result)

We have this function. It is called "test" (and more flexible than
your proposal).

It causes occasional questions on the mailing lists because
it does not behave as one expects of an if-then-else.

The main problem:

    if existence_of_some_object
    then: expression_depending_on_this_object
    else: alternative_expression

cannot be expressed with "test" (or whatever function, unless
Python changes function call semantics).

*Provided*, "expression_depending_on_this_object" does not
evaluate to a Python false value,

         and expression_depending_on_this_object
         or alternative_expression

can be used. However, this is less clear (than an explicit
"if-then-else" expression) and error prone (due to the
*provided* condition).


Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to