Skip to main content

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

Project description

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().

  • tail - read lines from the end of a file

  • head - read lines from the top of a file

  • follow - read lines as a file grows

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.

Installation

Install with pip or easy_install.

pip install tailer

Examples

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

Tail

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

Follow

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

Running Tests

Tailer currently only has doctests.

Run tests with nose:

nosetests --with-doctest src/tailer

Run tests with doctest:

python -m doctest -v src/tailer/__init__.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tailer-0.3.tar.gz (7.4 kB view details)

Uploaded Source

File details

Details for the file tailer-0.3.tar.gz.

File metadata

  • Download URL: tailer-0.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tailer-0.3.tar.gz
Algorithm Hash digest
SHA256 f026b22c312197e91c08115c795510ab5b22ec39e28b7b0c9e90100bb275a92d
MD5 9d1fc073e48ca682786d50c077e823ce
BLAKE2b-256 d7890b7ef6d3663e7c96d5aa86fe2457afb9c6d6e5f2e9706c8d0a5f7931c6e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page