configobj validation

Diez B. Roggisch deets at web.de
Wed Mar 21 07:40:56 EDT 2012


Andrea Crotti <andrea.crotti.0 at gmail.com> writes:

> On 03/19/2012 12:59 PM, Andrea Crotti wrote:
>> I seemed to remember that type validation and type conversion worked
>> out of the box, but now
>> I can't get it working anymore.
>>
>> Shouldn't this simple example actually fail the parsing (instead it
>> parses perfectly port to a string)?
>>
>> sample.py:
>> from configobj import ConfigObj
>>
>> conf = ConfigObj('sample.conf', configspec='sample.spec')
>>
>> sample.conf:
>> port = some_string
>>
>> sample.spec:
>> port = integer(0, 10)
>>
>> PS. using configobj 4.7.2
>
> I now checked the repo and configobj seems also quite dead (2 years
> ago last version), it's a pity because it's a really nice library.
> Any other alternatives for validation/configuration systems otherwise?

It works - so why do you bother? And I'm not sure about the above code -
AFAIK, validation is a two-step thing:

http://www.voidspace.org.uk/python/articles/configobj.shtml#validation

Diez



More information about the Python-list mailing list