def tail(target, lines=None):
 if isinstance(target, str):
  with open(target) as target_file:
   for line in tail(target_file, lines):
    (yield line)
   return
 target.seek(0, 2)
 block_end_byte = target.tell()
 block_number = (-1)
 content = ''
 while (((lines is None) or (lines > 0)) and (block_end_byte > 0)):
  if ((block_end_byte - BLOCK_SIZE) > 0):
   target.seek((block_number * BLOCK_SIZE), 2)
   (content, completed_lines) = (target.read(BLOCK_SIZE) + content).split('\n', 1)
  else:
   target.seek(0, 0)
   completed_lines = (target.read(block_end_byte) + content)
  for line in reversed(completed_lines.splitlines()):
   if ((lines is None) or (lines > 0)):
    if (lines is not None):
     lines -= 1
    (yield line)
  block_end_byte -= BLOCK_SIZE
  block_number -= 1

def tail ( target , lines = None ) : if isinstance ( target , str ) : with open ( target ) as target_file : for line in tail ( target_file , lines ) : ( yield line ) return target . seek ( 0 , 2 ) block_end_byte = target . tell ( ) block_number = ( - 1 ) content = '' while ( ( ( lines is None ) or ( lines > 0 ) ) and ( block_end_byte > 0 ) ) : if ( ( block_end_byte - BLOCK_SIZE ) > 0 ) : target . seek ( ( block_number * BLOCK_SIZE ) , 2 ) ( content , completed_lines ) = ( target . read ( BLOCK_SIZE ) + content ) . split ( '\n' , 1 ) else : target . seek ( 0 , 0 ) completed_lines = ( target . read ( block_end_byte ) + content ) for line in reversed ( completed_lines . splitlines ( ) ) : if ( ( lines is None ) or ( lines > 0 ) ) : if ( lines is not None ) : lines -= 1 ( yield line ) block_end_byte -= BLOCK_SIZE block_number -= 1
show and then tail the event log .