Hacker News new | ask | show | jobs
by _paulc 3084 days ago
Actually this is pretty simple if you use ConfigParser properly:

  # test.ini
  [host1]
  ip = 1.2.3.4
  [host2]
  ip = 5.6.7.8
  [host3]
  ip = 9.10.11.12

  # config.py
  import configparser

  c = configparser.ConfigParser()
  c.read("test.ini")
  ips = [ c[host]['ip'] for host in c.sections() ]