{"library":"configparser","code":"import configparser\nimport os\n\n# Create a configuration file programmatically\nconfig = configparser.ConfigParser()\nconfig['DEFAULT'] = {\n    'ServerAliveInterval': '45',\n    'Compression': 'yes',\n    'ForwardX11': 'yes'\n}\nconfig['production.server'] = {\n    'User': 'prod_user',\n    'Port': '50022',\n    'ForwardX11': 'no'\n}\n\nconfig_file_path = 'example.ini'\nwith open(config_file_path, 'w') as configfile:\n    config.write(configfile)\n\nprint(f\"Configuration written to {config_file_path}\")\n\n# Read the configuration file\nread_config = configparser.ConfigParser()\nread_config.read(config_file_path)\n\n# Access values using dictionary-like syntax\nprint(f\"Compression for DEFAULT: {read_config['DEFAULT']['Compression']}\")\nprint(f\"User for production.server: {read_config['production.server']['User']}\")\n\n# Get a value with fallback\nport = read_config.get('development.server', 'Port', fallback='22')\nprint(f\"Port for development.server (with fallback): {port}\")\n\n# Clean up the created file\nos.remove(config_file_path)\nprint(f\"Cleaned up {config_file_path}\")","lang":"python","description":"This quickstart demonstrates how to create a configuration, write it to an INI file, and then read values back using the `ConfigParser` class. It shows basic section and option access, as well as using fallback values for non-existent options.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}