Skip to content

Add DotDict() class#387

Open
chrimaho wants to merge 2 commits intomahmoud:masterfrom
chrimaho:add_dot_dict
Open

Add DotDict() class#387
chrimaho wants to merge 2 commits intomahmoud:masterfrom
chrimaho:add_dot_dict

Conversation

@chrimaho
Copy link
Copy Markdown

@chrimaho chrimaho commented Aug 2, 2025

This pull request introduces several changes to boltons/dictutils.py, focusing on code style improvements, bug fixes, and the addition of a new utility class. The most notable change is the introduction of the DotDict class, which provides dot notation access for dictionary keys. Other changes include consistent string formatting, improved readability, and minor adjustments to existing methods.

New Feature:

  • DotDict class: Added a new utility class that allows dot notation access to dictionary keys, with automatic conversion of nested dictionaries into DotDict instances. Includes methods for updating, deleting, and converting back to a regular dictionary. [1]

Code Style Improvements:

  • String formatting: Updated all string literals to use double quotes for consistency. This change applies across multiple methods, such as __init__, __eq__, poplast, and __repr__. [1] [2] [3] [4] [5] [6] [7]
  • List comprehensions and dictionary comprehensions: Reformatted multi-line comprehensions for better readability, such as in sortedvalues and __init__ methods. [1] [2]

Refactoring:

  • Improved readability: Reformatted complex conditionals and multi-line statements, such as in _insert, update, and __eq__ methods, to enhance clarity. [1] [2] [3]
  • __slots__ adjustments: Updated __slots__ definitions in classes like OneToOne and FrozenDict to use double quotes for consistency. [1] [2]

Minor Adjustments:

  • Imports: Reordered imports for better readability.
  • Whitespace: Added or removed blank lines to adhere to PEP 8 guidelines, such as in class definitions and method bodies. [1] [2] [3]

@chrimaho
Copy link
Copy Markdown
Author

Hi @mahmoud, have you had a chance to check this one out? It think it would make a nice addition to your package.

@mahmoud
Copy link
Copy Markdown
Owner

mahmoud commented Jan 28, 2026

Oh hey! This is fun. @kurtbrose and I played around with a much more minimal approach to this back in the day: https://www.pythondoeswhat.com/2010/12/attributedict-dictionary-whose-keys-are.html

These days I recommend using glom instead of changing the type.

@chrimaho
Copy link
Copy Markdown
Author

chrimaho commented Feb 3, 2026

Hey @mahmoud and @kurtbrose, thanks kindly.
Do you think we can consider whether this PR can be merged in to the core of this library?
I'm keen to use it more widely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants