{"id":2489,"library":"easydict","title":"EasyDict for Python Dictionaries","description":"EasyDict is a Python library that enables accessing dictionary values as attributes, providing a JavaScript-like dot notation for Python dictionaries. It works recursively for nested structures, making dictionary manipulation more convenient and readable. The current version is 1.13, and the library receives updates periodically, with several releases each year to address bugs and introduce minor enhancements.","status":"active","version":"1.13","language":"en","source_language":"en","source_url":"https://github.com/makinacorpus/easydict","tags":["dictionary","attribute access","dot notation","json"],"install":[{"cmd":"pip install easydict","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The class is named `EasyDict`. `edict` is a popular alias used in many examples for brevity.","wrong":"from easydict import EasyDict as edict # Not 'wrong', but 'EasyDict' is the primary class name; 'edict' is a common alias.","symbol":"EasyDict","correct":"from easydict import EasyDict"}],"quickstart":{"code":"from easydict import EasyDict\n\n# Create an EasyDict from a dictionary\ndata = EasyDict({\n    'settings': {\n        'debug': True,\n        'api_key': 'abc123xyz'\n    },\n    'users': [\n        {'id': 1, 'name': 'Alice'},\n        {'id': 2, 'name': 'Bob'}\n    ]\n})\n\n# Access values using dot notation\nprint(f\"Debug mode: {data.settings.debug}\")\nprint(f\"API Key: {data.settings.api_key}\")\nprint(f\"First user's name: {data.users[0].name}\")\n\n# Set new attributes or modify existing ones\ndata.settings.debug = False\ndata.new_feature = {'enabled': True}\nprint(f\"New debug mode: {data.settings.debug}\")\nprint(f\"New feature enabled: {data.new_feature.enabled}\")\n\n# EasyDict still behaves like a dict\nprint(f\"All keys: {list(data.keys())}\")","lang":"python","description":"Demonstrates creating an EasyDict from a Python dictionary, accessing nested values with dot notation, modifying attributes, and showing that it retains dictionary-like behavior."},"warnings":[{"fix":"Access non-string keys using `my_easydict[123]` instead of `my_easydict.123`.","message":"EasyDict is primarily designed for string keys when using dot notation. Attempting to access non-string keys (e.g., integers) as attributes will result in an AttributeError. You must use standard dictionary bracket notation for non-string keys.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware of the recursive conversion. If you need a plain dictionary, convert explicitly using `dict(my_easydict)` (note: this might not recursively convert nested EasyDicts back to plain dicts in older versions, requiring manual deep conversion). For `RecursionError` with class members, upgrade to >=1.11.","message":"EasyDict recursively converts nested dictionaries and lists of dictionaries into EasyDict instances. This can sometimes lead to unexpected behavior if strict Python dict/list types are expected at certain levels, or if dealing with self-referencing dictionary structures, which can cause `RecursionError`.","severity":"gotcha","affected_versions":"<= 1.10 for `RecursionError` with class members (fixed in 1.11), but recursive conversion applies to all versions."},{"fix":"Upgrade to EasyDict version 1.12 or newer to ensure tuples are preserved as tuples.","message":"In versions prior to 1.12, tuples assigned as values within an EasyDict could be incorrectly converted to lists. This could alter data structures unintentionally.","severity":"breaking","affected_versions":"< 1.12"},{"fix":"Upgrade to EasyDict version 1.9 or newer to ensure correct functionality of `.pop()` and `.update()`.","message":"The `.pop()` and `.update()` methods had incorrect behavior in versions prior to 1.9, particularly when dealing with EasyDict instances.","severity":"breaking","affected_versions":"< 1.9"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}