1. Home
  2. Computing & Technology
  3. Python

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

From , former About.com Guide

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

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

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

  1. Home
  2. Computing & Technology
  3. Python

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

All rights reserved.