configobj
doesn't support lists the way you're trying to use them, but as comma separated values:
[fruit]
favourite = Apple, Orange
In your code you just have to access the attribute as usual:
>>> cfg = configobj.ConfigObj('basket.ini')
>>> cfg['fruit']['favourite']
['Apple', 'Orange']
For more information, please have a look at this article.
Edit: If you really need to support configuration file with exactly the same format as in your question, note that it would be easy to write a custom parser for it:
import re
from collections import defaultdict
def parse(f):
data = defaultdict(list)
section = None
for line in f:
line = line.strip()
if not line:
continue
match = re.match('\[(?P<name>.*)\]', line)
if match:
section = match.group('name')
else:
data[section].append(line)
return data
cfg = parse(open('basket.ini'))
print cfg['favoFruit']
Example output:
['Apple', 'Orange']