<s> from rx import Observable , AnonymousObservable <EOL> from rx . internal . utils import adapt_call <EOL> from rx . internal import extensionmethod <EOL> @ extensionmethod ( Observable , alias = "<STR_LIT>" ) <EOL> def where ( self , predicate ) : <EOL> """<STR_LIT>""" <EOL> predicate = adapt_call ( predicate ) <EOL> parent = self <EOL> def subscribe ( observer ) : <EOL> count = [ <NUM_LIT:0> ] <EOL> def on_next ( value ) : <EOL> try : <EOL> should_run = predicate ( value , count [ <NUM_LIT:0> ] ) <EOL> except Exception as ex : <EOL> observer . on_error ( ex ) <EOL> return <EOL> else : <EOL> count [ <NUM_LIT:0> ] += <NUM_LIT:1> <EOL> if should_run : <EOL> observer . on_next ( value ) <EOL> return parent . subscribe ( on_next , observer . on_error , observer . on_completed ) <EOL> return AnonymousObservable ( subscribe ) </s>
