pickledb icon indicating copy to clipboard operation
pickledb copied to clipboard

feature: Return None instead of False

Open j123b567 opened this issue 5 years ago • 2 comments

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.

j123b567 avatar Jun 16 '20 12:06 j123b567

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

patx avatar Oct 07 '20 02:10 patx

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.

j123b567 avatar Oct 07 '20 07:10 j123b567