My favorites | Sign in
Project Logo
                
Show all Featured downloads:
tailer-0.2.1.tar.gz
Feeds:
People details
Project owners:
  msthornton

Python tail is a simple implementation of GNU tail and head.

It provides 3 main functions that can be performed on any file-like object that supports seek() and tell().

It also comes with pytail, a command line version offering the same functionality as GNU tail. This can be particularly useful on Windows systems that have no tail equivalent.

To easy install:

easy_install tailer

Examples

f = open('test.txt', 'w')
for i in range(11):
    f.write('Line %d\n' % (i + 1))
f.close()

import tailer

# Get the last 3 lines of the file
tailer.tail(open('test.txt'), 3)
# ['Line 9', 'Line 10', 'Line 11']

# Get the first 3 lines of the file
tailer.head(open('test.txt'), 3)
# ['Line 1', 'Line 2', 'Line 3']

# Follow the file as it grows
for line in tailer.follow(open('test.txt')):
    print line








Hosted by Google Code