hab von hier
http://docs.python.org/library/configpa ... nfigParser
das Beispiel kopiert und bekomme anch der Ausführung immer Syntax Fehler line32
Ich weiß nicht, wieso der Fehler kommt und das example.cfg nicht geschrieben wird, hab eine leere Datei example.cfg sogar schon im Verzeichnis angelegt und entsprechende Rechte vergeben.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import subprocess, popen2
import md5
import os.path
import distutils.util
import ConfigParser
import shutil
#
#
config = ConfigParser.RawConfigParser()
# When adding sections or items, add them in the reverse order of
# how you want them to be displayed in the actual file.
# In addition, please note that using RawConfigParser's and the raw
# mode of ConfigParser's respective set functions, you can assign
# non-string values to keys internally, but will receive an error
# when attempting to write to a file or when you get it in non-raw
# mode. SafeConfigParser does not allow such assignments to take place.
config.add_section('Section1')
config.set('Section1', 'int', '15')
config.set('Section1', 'bool', 'true')
config.set('Section1', 'float', '3.1415')
config.set('Section1', 'baz', 'fun')
config.set('Section1', 'bar', 'Python')
config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
# Writing our configuration file to 'example.cfg'
with open('/extras/programmieren/example.cfg', 'wb') as configfile:
config.write(configfile)
mfg und und ein gutes neues jahr
schwedenmann
[/quote]