parsing text

anthonydelorenzo at anthonydelorenzo at
Fri Feb 4 14:52:46 EST 2000

> Hi again, I'm currently having a problem parsing text, reading it actually. I'm
> trying to read a config file in the form of name=value I'd need to search for
> name, and return value. If anyone has any code snippets that do nething like
> this I would appreciate it.

Assuming that you decide not to directly import it, as was suggested, you
could do something like this, assuming that each item is on a different line.
 This would give you a dictionary of values.

import string
configfile = open ('filename.ext','r')
name, value = string.split(configfile.readline(),'=')
config[name] = value


Sent via
Before you buy.

More information about the Python-list mailing list