examples/other/data.ini
# comment

      # deep comment

outer = 42

[person]
fname = Foo
lname=Bar
phone =    123

[company]
name = Acme Corp.
phone = 456

examples/other/ini_parser.py
#!/usr/bin/python

import sys
import re

def parse():
  if len(sys.argv) != 2:
    print "Usage: " + sys.argv[0] + "  FILEAME"
    exit()
  filename = sys.argv[1]
  data = {}
  # print "Dealing with " + filename
  fh = open(filename, 'r')
  section = '__DEFAULT__'
  for line in fh:
    if re.match(r'^\s*(#.*)?$', line):
      continue
    m = re.match(r'^\[([^\]]+)\]\s*$', line)
    if (m):
      #print 'Section "{}"'.format(m.group(1))
      section = m.group(1)
      continue
    m = re.match(r'^\s*(.+?)\s*=\s*(.*?)\s*$', line)
    if m:
        #print 'field :"{}"  value: "{}"'.format(m.group(1), m.group(2))
        if not data.get(section):
           data[section] = {}
        data[section][ m.group(1) ] = m.group(2)

  return data

ini = parse()
print ini