#!/usr/bin/python import struct import mmap f = open("test.dat", "rb+") mm = mmap.mmap(f.fileno(),3) print len(mm) print "first 3 bytes: " + mm[0:3];