Having played around with trying to use and/or to force python into
a more C-like expression oriented pattern lately in my Obfuscated
Python posts, this comes to mind:
>>> ((( 1 < 2 ) and ( 'Less Than' ) or ( 'Not Less Than' )))
'Less Than'
>>> ((( 3 < 2 ) and ( 'Less Than' ) or ( 'Not Less Than' )))
'Not Less Than'
But I think the following is more python-ish:
>>> ( 'Not Less Than', 'Less Than' )[ ( 1 < 2 ) ]
'Less Than'
>>> ( 'Not Less Than', 'Less Than' )[ ( 3 < 2 ) ]
'Not Less Than'
i.e. using the boolean False = 0 / True = 1 to map into a
tuple index. BUT: since None and empty sequences are also
false and all others true, there is no guarantee that this
will work for all tests.
Predictions:
Tim will love it!
Guido *may* feel a bit ill at our continual efforts to make python
look like C !
- sdm