toejough / dictmerge Goto Github PK
View Code? Open in Web Editor NEWmerge python dictionaries
License: MIT License
merge python dictionaries
License: MIT License
the fix for #11 removed the default rule from Pedantic merge, but the correct place for the fix is in BasePedanticMerge.
right now a missing rule will just trigger a key error on an internal dictionary. That sucks.
Just having the MERGE_FUNCTIONS global is ugly. Asking users to override things there is worse.
Leave the default 'merge' function, but create a Merge class which you can customize functions in, and then call via Merge.call.
'create' is misleading - this is really a 'set' function, as it's also the function used to override an already created rule.
suggest 'set_rule' and 'unset_rule' instead of 'create/delete'.
Like key, values
currently there are inconsistent names for the API:
consider updating the API to be:
A generator will be converted to a tuple right now. If it's an infinite generator, it will cause the merge to hang forever. Generators should be caught and treated as scalars when doing a default merge, because it's not possible to know the correct behavior and account for it generically in the default library.
After reflection, while I like the idea of true duck typing, this should not be the default. The rest of python doesn't work that way. The special typing thing could stick around, but make the default be idiomatic python.
When the resolver would be called, throw the KeyConflictError
...and re-raise better error messages. Like if a user passes in an integer instead of a dictionary, or if the resolver is not callable.
What if a user wants to actually combine strings? Or generators? Or custom merge functions for a custom class?
After implementing #1, make it possible to add custom merge functions to the Merge class (as distinct from just overriding existing functions/assignments).
It's reasonable for someone to want a dictionary merge that throws an exception when there are conflicts, or a set merge that does an intersection instead of a union, or a string merge that merges strings, or a generic iterable merge-to-list, or a generic iterable merge-to-set, etc.
Provide these in some sort of 'extras' struct or package, and maybe provide a few pre-customized Merge classes/functions.
Pedantic Merge has rules for default types, even though the default type is not defined in it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.