|
From: T. H. <har...@ya...> - 2008-12-01 22:40:46
|
Thanks for the fast response.
This is what I'm doing in my script to convert the single value to a list. Perhaps there is a better way.
if type(pathList) == type(''):
pathList = [pathList]
I don't really like the the special syntax with a trailing comma (similar to the python syntax to create a tuple with 1 element). It's easy to forget it yourself, but if other people are going to write ini files it's a disaster waiting to happen.
I haven't checked out configspec, but it looks like the way to go. For now I'm going to leave it the way it is - I may add a utility function to get values for keywords that should be lists.
Hari
----- Original Message ----
From: Michael Foord <fuz...@vo...>
To: T. Hariharan <har...@ya...>; con...@li...
Sent: Monday, December 1, 2008 2:24:40 PM
Subject: Re: [Configobj-develop] List values
T. Hariharan wrote:
> When you have a keyword that has a list of values, eg:
>
> PathList = /path1, /path2
>
> config['PathList'] returns a list of values. However if you have only one value:
>
> PathList = /path1
>
> config['PathList'] returns a string value.
>
> It would be nice if you can tell ConfigObj to always return values for certain keywords as a list, even if there is only one value. In the second case above, config['PathList'] would return [ '/path1' ]. Is there a way to do this? I'm sure others would have run into this issue.
>
An even better way to achieve this would be to create a custom
configspec with a check function that can take a single value or a list
and always returns a list.
All the best,
Michael Foord
> Thanks,
> Hari
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|