My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
configparser  
Introduction to using configparser
Phase-Implementation, Phase-Design
Updated Nov 11, 2012 by eski...@gmail.com

See Also Python Docs

Introduction

Python 3 includes a module named configparser, that assists programmers interface with a configuration file. I recommend the usage of this module, but it is not required.

Recommended Usage

_name       # Name of game
fullconfig  # The entire config file, kept for saving
config      # The config data for this game only
_name = 'Game Name'

# Reading
fullconfig = configparser.ConfigParser()
fullconfig.read('config.ini')
config = fullconfig[_name]

# Saving
with open('config.ini') as configfile:
    fullconfig.write(configfile)

Configuration data for your module is stored in config as a dictionary.

Powered by Google Project Hosting