[FRPythoneers] Random File Access

Sean Reifschneider jafo at tummy.com
Tue Dec 23 20:45:36 MST 2003


On Tue, Dec 23, 2003 at 08:46:54PM -0700, J. Wayde Allen wrote:
>so that I'd read x bytes at a time.  However, I'm wondering if there is a
>more efficient mechanism or a way to perform a random access to the file
>data?  I do have information in the file that gives byte offsets to where
>these data I need are located.

   >>> fp = open('/etc/services', 'r')
   >>> print fp.read(20)
   # /etc/services:
   # $
   >>> fp.seek(10)
   >>> print fp.read(4)
   vice
   >>> fp.seek(8)
   >>> print fp.read(4)
   ervi
   >>> 

Sean
-- 
 Read error: 666 (Connection reset by Satan)
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin
      Back off man. I'm a scientist.   http://HackingSociety.org/



More information about the FRPythoneers mailing list