{"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":"python","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,"search_vec":"'1.13':44 'access':12,65 'address':57 'attribut':16,64 'bug':58 'conveni':37 'current':41 'dictionari':4,13,26,34,63 'dot':22,66 'easydict':1,5 'enabl':11 'enhanc':62 'introduc':60 'javascript':20 'javascript-lik':19 'json':68 'librari':9,47 'like':21 'make':33 'manipul':35 'minor':61 'nest':31 'notat':23,67 'period':50 'provid':17 'python':3,8,25 'readabl':39 'receiv':48 'recurs':29 'releas':53 'sever':52 'structur':32 'updat':49 'valu':14 'version':42 'work':28 'year':55","created_at":"2026-04-11T01:30:17.365956+00:00","updated_at":"2026-04-16T14:45:18.650514+00:00","problems":[{"fix":"pip install easydict","cause":"The easydict library is not installed in the Python environment where the code is being executed.","error":"ModuleNotFoundError: No module named 'easydict'"},{"fix":"Ensure the key 'some_key' actually exists in your EasyDict object. You can check its existence using `'some_key' in your_easydict` or safely retrieve its value using `your_easydict.get('some_key', default_value)` to avoid the error.","cause":"You are attempting to access a non-existent key as an attribute on an EasyDict object.","error":"AttributeError: 'EasyDict' object has no attribute 'some_key'"},{"fix":"Replace `.iteritems()` with `.items()` in your code.","cause":"This error occurs when running Python 2 code in a Python 3 environment. The `iteritems()` method for iterating over dictionary items was removed in Python 3 and replaced by `items()`.","error":"AttributeError: 'EasyDict' object has no attribute 'iteritems'"},{"fix":"Verify that 'some_key' exists before accessing it, or use the `.get()` method to provide a default value if the key is not found, e.g., `my_easydict.get('some_key', None)`.","cause":"When treating an EasyDict instance like a regular dictionary, you attempted to access a key using bracket notation (`my_easydict['some_key']`) that does not exist within the dictionary.","error":"KeyError: 'some_key'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.13","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/makinacorpus/easydict","docs":null,"changelog":null,"pypi":"https://pypi.org/project/easydict/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}