[Tutor] Question about ConfigParser
Jan Erik Moström
lists at mostrom.pp.se
Sat Jan 6 22:40:27 CET 2007
I'm trying to use ConfigParser for the first time and I'm
missing something. I have this code
import ConfigParser
import datetime
conf = ConfigParser.ConfigParser()
conf.add_section('general')
conf.set( 'general', 'revision', 0 )
conf.set( 'general', 'date',
datetime.datetime.now().strftime("%Y-%m-%d") )
conf.set( 'general', 'currentsetname', '' )
conf.set( 'general', 'incrementalcount', 0 )
conf.add_section( "Hello world" )
conf.set( "Hello world", 'apa', 3298 )
print conf.sections()
print conf.items('general')
#for debug_repos in conf.sections():
# print debug_repos #, conf.items( debug_repos )
When I run this I get the following result
['Hello world', 'general']
Traceback (most recent call last):
File "backup.py", line 15, in <module>
print conf.items('general')
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ConfigParser.py",
line 557, in items
for option in options]
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ConfigParser.py",
line 565, in _interpolate
if "%(" in value:
TypeError: argument of type 'int' is not iterable
What am I missing with the items call?
jem
More information about the Tutor
mailing list