Skip to main content
Build Status

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']

Head

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

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

Release files for tailer 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tailer 0.4.1
File Size Uploaded
tailer-0.4.1.tar.gz 7.5 kB Details

Release files / tailer-0.4.1.tar.gz

Download URL tailer-0.4.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78d60f23a1b8a2d32f400b3c8c06b01142ac7841b75d8a1efcb33515877ba531
BLAKE2b-256 checksum
How to use checksums
dd0501de24d6393d6da0c27857c76b0f9ae97b42cd6102bbdf76cce95e031295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.1 This release

1 release file

0.4

1 release file

0.3

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.1

1 release file

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page