Skip to content

Fix list indexing negative values#102

Open
ltorres6 wants to merge 3 commits intopawelzny:masterfrom
ltorres6:fix-list-indexing-negative-values
Open

Fix list indexing negative values#102
ltorres6 wants to merge 3 commits intopawelzny:masterfrom
ltorres6:fix-list-indexing-negative-values

Conversation

@ltorres6
Copy link
Copy Markdown

@ltorres6 ltorres6 commented Aug 4, 2023

minor change to allow for negative indexing (e.g. last element of list "-1"). Tests passing locally.

For example:

from dotty_dict import Dotty

i_dict = Dotty(
    {"some": {"nested": {"list": {"here": {"now": [0, 1, 2, 3]}}}}}
)

key = "some.nested.list.here.now.-1"
value = i_dict[key]
print(f"dict value: {value}")
print(f"key in i_dict is {key in i_dict}")
print(f"value type: {type(value)}")

should return

dict value: 3
key in i_dict is True
value type: <class 'int'>

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.

1 participant