observers in rxpy each of the above can be used as positional parameters or as keyword argumentsfor exampleuse lambdas to set up all three functions observable subscribeon_next lambda valueprint('received on_next'value)on_error lambda expprint('error occurred'exp)on_completed lambdaprint('received completed notification'the above code defines three lambda functions that will be called depending upon whether data is supplied by the observableif an error occurs or when the data stream is terminated the output from this isreceived on_next received on_next received on_next received on_next received completed notification note that the on_error function is not run as no error was generated in this example the final optional parameter to the subscribe(method is an observer object an observer object can implement the observer protocol which has the following methods on_next()on_completed(and on_error()for exampleclass primenumberobserverdef on_next(selfvalue)print('object received'valuedef on_completed(self)print('data stream completed'def on_error(selferror)print('error occurred'errorinstances of this class can now be used as an observer via the subscribe(methodsubscribe an observer object observable subscribe(primenumberobserver()the output from this example using the previous observable isobject received object received object received object received data stream completed note that the on_completed(method is also calledhowever the on_errror(method is not called as there were no exceptions generated