I don't think you can make ConfigParser
treat colons as anything but key/value delimiters. Thus, if you use colons, the hostnames will be interpreted as keys, which won't work for you because they are not unique. So you will probably have to change colons to something else. Then your entries will be unique. ConfigParser
supports keys without values:
In [1]: from ConfigParser import ConfigParser
In [2]: cp = ConfigParser(allow_no_value=True)
In [3]: cp.read('foo.conf')
Out[3]: ['foo.conf']
In [4]: cp.items('servers')
Out[4]:
[('localhost;1111', None),
('localhost;2222', None),
('localhost;3333', None),
('someserver;2222', None),
('someserver;3333', None)]
Another option is to add a unique ID to each line and also separate it by a colon. The rest will then become the value:
In [1]: from ConfigParser import ConfigParser
In [2]: cp = ConfigParser()
In [3]: cp.read('foo.conf')
Out[3]: ['foo.conf']
In [4]: cp.items('servers')
Out[4]:
[('1', 'localhost:1111'),
('2', 'localhost:2222'),
('3', 'localhost:3333'),
('4', 'someserver:2222'),
('5', 'someserver:3333')]