patx / pickledb

pickleDB is an open source key-value store using Python's json module.
https://patx.github.io/pickledb
BSD 3-Clause "New" or "Revised" License
925 stars 125 forks source link

feature: Return None instead of False #71

Open j123b567 opened 4 years ago

j123b567 commented 4 years ago

In latest versions, there was made bad decision to replace None with False. It is now not possible to distinguis between False and not set entry because neither KeyError nor None is returned like in all other standard python interfaces (eg. dict)

Only good way to solve this would be to mimic python dict and introduce full featured get() method with user configurable default argument, which is used when there is no entry in the db with default default set to None.

Please, can you revert it back and use None in every case, where there is no single item to return or at least introduce optional default argument, so it is possible for the user to overcome this bad decision without maintaining its own downstream version.

patx commented 4 years ago

Let me know which commit this change was made in so I can review, thanks.

j123b567 commented 4 years ago

89897b4e07a80b731ca5b4e2b2df5ca54e825871 This commit says that it is because of consistency, but it is against it.

None of lgetall, lget, lpop, dget, dpop return False in case of missing key. They will instead raise KeyError.

Other methods never return data so they are irrelevant for comparison.