pythonadvanced

Configparser Ini

Advanced Python pattern: configparser-ini

python
import configparser

cfg = configparser.ConfigParser()
cfg['app'] = {'host': 'localhost', 'port': '8000'}
with open('app.ini', 'w') as f:
    cfg.write(f)

cfg.read('app.ini')
print(cfg['app']['host'])

Use Cases

  • advanced programming
  • patterns

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.