Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] get_deep() method #14

Open
Marco-Sulla opened this issue Feb 1, 2020 · 2 comments
Open

[FEATURE] get_deep() method #14

Marco-Sulla opened this issue Feb 1, 2020 · 2 comments
Labels
Effort: Medium How to waste a beautiful weekend Needs: Doc Improvements or additions to documentation Needs: Test Hey, it compiles! Ship it! Priority: Low Not a big problem... Type: Enhancement New feature or request

Comments

@Marco-Sulla
Copy link
Owner

Marco-Sulla commented Feb 1, 2020

get_deep(*args, default=_sentinel) can accept a single argument, that must be an iterable, or multiple arguments.

The first element must be a key of the frozendict. If there's no a second element, the value is returned. If it's present, it tries to use it as argument for the eventual __getitem__() of the value object, and so on.

In this process, if a KeyError, an IndexError or a TypeError is raised, if default is set its value is returned, otherwise the exception will be re-raised.

Example:

fd = frozendict({1: [42]})
fd.get_deep(1, 0)
# 42
fd.get_deep(range(3), default=1981)
# 1981
fd.get_deep((1, 1))
# IndexError: list index out of range

See also #13

@Marco-Sulla Marco-Sulla added the Type: Enhancement New feature or request label Feb 1, 2020
@Marco-Sulla
Copy link
Owner Author

Implemented with 89517ad

@Marco-Sulla
Copy link
Owner Author

Reopening for reimplementing it, also in C Extension.

@Marco-Sulla Marco-Sulla reopened this Feb 25, 2023
@Marco-Sulla Marco-Sulla added Needs: Doc Improvements or additions to documentation Priority: Low Not a big problem... Effort: Medium How to waste a beautiful weekend Needs: Test Hey, it compiles! Ship it! and removed Status: Fixed Now it works! labels Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort: Medium How to waste a beautiful weekend Needs: Doc Improvements or additions to documentation Needs: Test Hey, it compiles! Ship it! Priority: Low Not a big problem... Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant