Встроенные комментарии для ConfigParser

У меня есть подобные вещи в .ini файле

[General]
verbosity = 3   ; inline comment

[Valid Area Codes]
; Input records will be checked to make sure they begin with one of the area 
; codes listed below.  

02    ; Central East New South Wales & Australian Capital Territory
03    ; South East Victoria & Tasmania
;04    ; Mobile Telephones Australia-wide
07    ; North East Queensland
08    ; Central & West Western Australia, South Australia & Northern Territory

Однако у меня есть проблема, что встроенные комментарии работают в строке key = value, но не в строке key без значения. Вот как я создаю свой объект ConfigParser:

>>> import ConfigParser
>>> c = ConfigParser.SafeConfigParser(allow_no_value=True)
>>> c.read('example.ini')
['example.ini']
>>> c.get('General', 'verbosity')
'3'
>>> c.options('General')
['verbosity']
>>> c.options('Valid Area Codes')
['02    ; central east new south wales & australian capital territory', '03    ; south east victoria & tasmania', '07    ; north east queensland', '08    ; central & west western australia, south australia & northern territory']

Как я могу настроить парсер конфигурации так, чтобы встроенные комментарии работали в обоих случаях?

5
задан Charles 29 February 2012 в 03:11
поделиться