{"library":"immutabledict","code":"from immutabledict import immutabledict\n\n# Create an immutable dictionary\nmy_item = immutabledict({\"a\": \"value\", \"b\": \"other_value\"})\n\nprint(f\"Value for 'a': {my_item['a']}\")\n\n# Attempting to modify an immutabledict will raise a TypeError\ntry:\n    my_item[\"c\"] = \"new_value\"\nexcept TypeError as e:\n    print(f\"Attempted modification failed: {e}\")\n\n# You can create a new immutabledict with changes using dictionary union operator (PEP 584)\nnew_item = my_item | {\"c\": \"another_value\"}\nprint(f\"New item (original unchanged): {new_item}\")\nprint(f\"Original item: {my_item}\")","lang":"python","description":"Demonstrates how to create an immutabledict and shows that direct modification attempts will result in a TypeError. It also illustrates how to create a new immutabledict based on an existing one with updates.","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}]}