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

Generate new dict from diff - dict of changes #171

Open
p-baum opened this issue Oct 18, 2022 · 1 comment
Open

Generate new dict from diff - dict of changes #171

p-baum opened this issue Oct 18, 2022 · 1 comment

Comments

@p-baum
Copy link

p-baum commented Oct 18, 2022

Maybe I've missed something but I cant see how to generate a diff dict.

I need a dict representation of the changes to simplify database updates. Is this possible?

@mikaelho
Copy link
Contributor

diff returns a generator. In your use case it sounds like you need to "instantiate" the diff with list, and if you need a dict, you need to wrap the result explicitly. So something like this?

diff_dict = {"changes": list(diff(a, b))}

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

No branches or pull requests

2 participants