[Tutor] troubles with ConfigParser

Eur van Andel eur at fiwihex.nl
Mon Nov 17 03:36:27 EST 2003

On Sun, 16 Nov 2003 03:56:37 +0100, Eur van Andel <eur at fiwihex.nl> wrote:

>There are some troubles,
>though, especially when writing an INI file. 

>#   st.write('settings.ini')
>>Traceback (most recent call last):
>>  File "st_try.py", line 81, in ?
>>    st.write('settings.ini')
>>  File "/usr/local/lib/python2.2/ConfigParser.py", line 351, in write
>>    fp.write("[%s]\n" % section)
>>AttributeError: 'str' object has no attribute 'write'

write(fp) expects a file pointer. So open a file first and pass the pointer:

sett = open('settings.ini, 'w')

Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
Wierdensestraat 74, NL-7604 BK  Almelo, The Netherlands   eur at fiwihex.nl
phone +31-546-491106  fax +31-546-491107  mobile +31-653-286573  

More information about the Tutor mailing list