1. Home
  2. Computing & Technology
  3. Python
photo of Al Lukaszewski

Al's Python Blog

By Al Lukaszewski, About.com Guide to Python

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.

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python

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

All rights reserved.