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

Add default to map filter if attribute is not defined #557

Closed
Yannik opened this issue Mar 1, 2016 · 7 comments · Fixed by #1018
Closed

Add default to map filter if attribute is not defined #557

Yannik opened this issue Mar 1, 2016 · 7 comments · Fixed by #1018

Comments

@Yannik
Copy link

@Yannik Yannik commented Mar 1, 2016

It would be great if the map filter would return an optional default value if the attribute is not defined.

Example:

list_of_dicts|map(attribute='version', default='5.6')
@esaezgil

This comment has been minimized.

Copy link

@esaezgil esaezgil commented Oct 11, 2017

Hi @DanyC97 and @Yannik thanks for raising this! :) it's been so long that the MR has conflicts. I will try to solve them asap

@pallets pallets deleted a comment from esaezgil Oct 11, 2017
@pallets pallets deleted a comment from DanyC97 Oct 11, 2017
@pallets pallets deleted a comment from Yannik Oct 11, 2017
@pallets pallets deleted a comment from hsychla Dec 8, 2017
@wedi

This comment has been minimized.

Copy link

@wedi wedi commented Mar 22, 2018

Are there any news regarding this feature? Why was the pulled request closed? Should someone else take over or is this just undesired?

@esaezgil

This comment has been minimized.

Copy link

@esaezgil esaezgil commented Mar 22, 2018

I closed the pull request myself as I do not have any further interest pursuing it. Please feel free to contribute with another PR.

@akamac

This comment has been minimized.

Copy link

@akamac akamac commented Jul 5, 2018

I would love to see this implemented

@shashanksingh28

This comment has been minimized.

Copy link

@shashanksingh28 shashanksingh28 commented May 6, 2019

Working on this in Pycon 2019 Sprints

@kbiggers

This comment has been minimized.

Copy link
Contributor

@kbiggers kbiggers commented Jun 11, 2019

@flexferrum

This comment has been minimized.

Copy link
Contributor

@flexferrum flexferrum commented Jun 14, 2019

Is it a good idea to add 'default' param to the 'attr' filter as well? As a shorthand for someVal | attr('someAttr') | default(10)

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

Successfully merging a pull request may close this issue.

9 participants
You can’t perform that action at this time.