Skip to content

Instantly share code, notes, and snippets.

@rez0n
Created June 26, 2014 15:57
Show Gist options
  • Save rez0n/c3281f52496ee931f864 to your computer and use it in GitHub Desktop.
Save rez0n/c3281f52496ee931f864 to your computer and use it in GitHub Desktop.
Create config with default values in ConfigObj
import configobj
def default_config():
config = configobj.ConfigObj('d:\\text.txt')
config['settings'] = {}
config['settings']['my_ip'] = None
config['settings']['rtsp_port'] = '5180'
config['settings']['http_port'] = '5081'
config.write()
try:
open('d:\\text.txt')
except IOError:
print("Config is epsent. Creating defaul")
default_config()
else:
print('Config good')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment