1. Home
  2. Computing & Technology
  3. Python

Part 2: Getting Feed Information From the Data File With Python

From Al Lukaszewski, for About.com

7 of 9

Reading the RSS Feed as a Python File Object

Now, we are ready to read from the file object. Every file object has several open, read, write, and close methods that can be called. The most common ones are discussed in my tutorials on file handling. For our purposes, we will read the file into a dictionary.

Before starting the iteration, we read one line into a variable line and initiate an empty dictionary. Let's call it record.

     line = datafile.readline()
     record = {}

If you need more help with dictionaries, you can get a quick tutorial or review in my beginner's tutorial.

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.