#NEWLINE# @ extensionmethod ( Observable ) #NEWLINE# def take_last( self , count ) : #NEWLINE# #INDENT# 'Returns a specified number of contiguous elements from the end of an\n    observable sequence.\n\n    Example:\n    res = source.take_last(5)\n\n    Description:\n    This operator accumulates a buffer with a length enough to store\n    elements count elements. Upon completion of the source sequence, this\n    buffer is drained on the result sequence. This causes the elements to be\n    delayed.\n\n    Keyword arguments:\n    :param int count: Number of elements to take from the end of the source\n        sequence.\n\n    :returns: An observable sequence containing the specified number of elements \n        from the end of the source sequence.\n    :rtype: Observable\n    ' #NEWLINE# source = subscribe #NEWLINE# def subscribe( observer ) : #NEWLINE# #INDENT# q = [ ] #NEWLINE# def on_next( x ) : #NEWLINE# #INDENT# q . append ( x ) #NEWLINE# if ( len ( q ) > count ) : #NEWLINE# #INDENT# q . pop ( 0 ) #NEWLINE# #UNINDENT# #UNINDENT# def on_completed( ) : #NEWLINE# #INDENT# while len ( q ) : #NEWLINE# #INDENT# observer . on_next ( q . pop ( 0 ) ) #NEWLINE# #UNINDENT# observer . on_completed ( ) #NEWLINE# #UNINDENT# return source . subscribe ( on_next , observer . on_error , on_completed ) #NEWLINE# #UNINDENT# return AnonymousObservable ( subscribe )