1. Home
  2. Computing & Technology
  3. Python
Python Blog

From Al Lukaszewski, for About.com

Seek and Read Quickly With the os Module

Tuesday May 6, 2008
Some protocols communicate data in forms that are less than human-friendly. Unlike XML, some communication protocols as well as older data formats can be downright obtuse. It is not unheard of for some to require the appending of a certain number of signature characters to a particular point of a data packet, usually the beginning or the end. While jobs involving these formats typically include building a parser, if one is not already built, the efficiency with which the packet is parsed inevitably reflects on you. Rather than read the file in toto, it may be worth considering a partial read. To affect this efficiently, use Python's os functions lseek() and read(). To learn how, see "lseek() and ye can read()", the latest segment in the series on the os module.
Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.