multiple pattern regular expression

python at bdurham.com python at bdurham.com
Fri Apr 25 09:50:56 EDT 2008


How about this?

for line in file:
    # ignore lines without = assignment
    if '=' in line:
        property, value = line.strip().split( '=', 1 )
        property = property.strip().lower()
        value = value.strip()

        # do something with property, value

Malcolm



More information about the Python-list mailing list