Conditional Python SequenceIterator Methods

The following conditional methods apply the object's boolean sequence to the input sequence(s). These methods are of the following types:

The operation can be one of the following:

iif( then, else)

 

Choose the element of the then sequence or the else sequence depending on the boolean value of the element of the object's condition sequence. All three sequences are traversed at the same speed (if the element of the then sequence is used, then the element of else sequence is skipped and visa versa). (Please see the Ternary Operations page for further details.)

 

if( then, else) Choose the element of the then sequence or the else sequence depending on the boolean value of the element of the object's condition sequence. Unlike iif(), the position in the sequence not used is not changed.

(Please see the Ternary Operations page for further details.)

filter(input)

Returns a sequence of the same type as input with only the elements corresponding to true elements in the object's condition sequence

filter_pos()

Returns an integer sequence with the positions of the true elements in the object's condition sequence

Example

Following is an example code snippet demonstrating a conditional method:

     
    cursor = con.cursor("Quote", "by_sym")
    for quote in cursor:
        ...
        last = quote.day.last();
        dayit = quote.day.search(DMY(1,MONTH(last),YEAR(last)), 
                exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE, 
                last, 
                exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE)
        openit,closeit = dayit.project('open', 'close')
        gtit = closeit.gt(openit)
        filtit = gtit.filter(dayit)
        ...